This week's book giveaway is in the Beginning Java forum.
We're giving away four copies of Murach's Java Programming and have Joel Murach on-line!
See this thread for details.
Win a copy of Murach's Java Programming this week in the Beginning Java forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Concurrent processing by threads.  RSS feed

 
yamini nadella
Ranch Hand
Posts: 257
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Friends,
I am trying to implement concurrence processing in java by threads.
From a main process I want to start 2 child processes. Then main process has to wait until all of its child processes got completed. Here 2 child processes can run parallel.
So how can I stop main thread until all children execution get completed.
Thanks in advance,
Yamini.
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24217
38
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Use the "join()" method. Call it on each thread that you want to wait for, one after the other. You won't get past the last call until all the child threads have completed.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!