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


JavaRanch » Java Forums » Java » Threads and Synchronization
Bookmark "join method" Watch "join method" New topic
Author

join method

abalfazl hossein
Ranch Hand

Joined: Sep 06, 2007
Posts: 635
There may be situations when the current thread's execution should be halted until another thread 'A' completes execution. This may be accomplished by invoking the join method on thread A. Using A.join() within a thread is tantamount to making the current thread sleep until thread 'A' completes execution.




http://www.edumax.com/java-basics-thread-join.html


I know how the join method works, But my questions which situation or scenario can happened in real world, that the usage of join method is needed?
Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

your quote itself is a real time scenario. you will experience this when you work in muti threaded environment.
Jim Hoglund
Ranch Hand

Joined: Jan 09, 2008
Posts: 525
An example would be a document to reformat and then print. Start the reformatting operation
in a thread and then launch a print thread. But have the print thread join the formatting thread.
The main thread can then go on to other tasks.

Jim ... ...


BEE MBA PMP SCJP-6
 
GeeCON Prague 2014
 
subject: join method