This week's book giveaway is in the HTML/CSS/JavaScript forum.
We're giving away four copies of Practical SVG and have Chris Coyier on-line!
See this thread for details.
Win a copy of Practical SVG this week in the HTML/CSS/JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

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

 
ranua agarwal
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Sheriff
Posts: 24213
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Right before sendEmail(), call

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

and that's it!
 
It's a beautiful day in this neighborhood - Fred Rogers. Tiny ad:
the new thread boost feature: great for the advertiser and smooth for the coderanch user
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!