Two Laptop Bag
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes join() Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "join()" Watch "join()" New topic


Vikrama Sanjeeva
Ranch Hand

Joined: Sep 02, 2001
Posts: 756
Hi guyz.I have not understand the function of join().A/C to me it waits to join the curently running thread to which it is joined.
If it is correct then plz. explain it
Count the flowers of ur garden,NOT the leafs which falls away!

Count the flowers of your garden, NOT the leafs which falls away!
Prepare IBM Exam 340 by joining
Jim Hall
Ranch Hand

Joined: Nov 29, 2001
Posts: 162
The join() method is an instance method of the Thread class. So when a running thread (A) calls the join method on another thread (B).It (A) waits until that thread (B) dies before it proceeds.
Peter den Haan
Ranch Hand

Joined: Apr 20, 2000
Posts: 3252
In practical terms:- say you need to do two time-consuming, I/O bound jobs A and B. Say they are implemented in two Runnable classes A and B. You need both to be finished in order to carry on.
Because they are I/O bound, it makes a lot of sense to run A and B in parallel using threads:The b.join() statement ensures that the doWork method will only return once both job A and job B have been finished.
- Peter
I agree. Here's the link:
subject: join()
It's not a secret anymore!