This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes java how to join a thread after completion of another two thread Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "java how to join a thread after completion of another two thread" Watch "java how to join a thread after completion of another two thread" New topic
Author

java how to join a thread after completion of another two thread

ranua agarwal
Greenhorn

Joined: Mar 31, 2010
Posts: 25
Hi,

I have two different thread.
One for getting data from database, another for getting data from file system.
These two thread are independent of each other.
Once both get completed, need to send mail which contains fetched data from database and filsystem as well.

function call is as follows:



Now how to make sure that mail will be send only when both thread (thread1 and thread2) will be finished?

Thanks,
Ranu.
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24183
    
  34

Right before sendEmail(), call

thread1.join();
thread2.join();

and that's it!


[Jess in Action][AskingGoodQuestions]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: java how to join a thread after completion of another two thread
 
Similar Threads
Thread synchronization
join() method usage
Threads
problem with monitors :
Question on Threads