aspose file tools*
The moose likes Beginning Java and the fly likes Do I need to do a Thread.join() ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Do I need to do a Thread.join() ?" Watch "Do I need to do a Thread.join() ?" New topic
Author

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

Pho Tek
Ranch Hand

Joined: Nov 05, 2000
Posts: 761

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

    Joined: Mar 10, 2008
    Posts: 326

    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.
     
    I agree. Here's the link: http://aspose.com/file-tools
     
    subject: Do I need to do a Thread.join() ?