GeeCON Prague 2014*
The moose likes Threads and Synchronization and the fly likes Concurrent processing by threads. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Threads and Synchronization
Bookmark "Concurrent processing by threads." Watch "Concurrent processing by threads." New topic
Author

Concurrent processing by threads.

yamini nadella
Ranch Hand

Joined: Apr 13, 2004
Posts: 257
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
Marshal

Joined: Jul 08, 2003
Posts: 24187
    
  34

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.


[Jess in Action][AskingGoodQuestions]
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Concurrent processing by threads.