Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Do I need to do a Thread.join() ?

 
Pho Tek
Ranch Hand
Posts: 782
Chrome Python Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a Servlet which instantiates a Service class and invokes a method (which I'll call doStuff).

Since the method sendToRemoteServer takes a long time, can I safely:
  • run it in a Thread ?
  • If yes to the previous question, do I need to join this Thread ? i.e. do I need to call thread.join() whereby thread is the reference to the Thread that executes "sendToRemoteServer".

  • Thanks all

    Regards,

    Pho
     
    Ove Lindström
    Ranch Hand
    Posts: 326
    Android Firefox Browser Mac OS X
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    I would implement the print-job as a Task and then have an Excecutor-object run it. If you need to have some sort of callback when it is done, you can use a Semaphore or a CountDownLatch.
     
    • Post Reply
    • Bookmark Topic Watch Topic
    • New Topic