wood burning stoves 2.0*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Thread join() method 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 "Thread join() method" Watch "Thread join() method" New topic
Author

Thread join() method

Shiva Mohan
Ranch Hand

Joined: Jan 05, 2006
Posts: 477



join() is called on Thread-1(that means, reference a) and called by mainthread.That means mainthread will wait until the thread-1(a) will die.
So thread-1 is completed first holding 1 value.then that(1) value is printed for a.i.

I wanted to make sure that I got the join() method correctly.Am i correct...
Naseem Khan
Ranch Hand

Joined: Apr 25, 2005
Posts: 809
Yes you are correct.

Here, a.join() means main thread will wait for a to complete. By this way, a will successfully assign 1 to i before main thread prints it.

Naseem


Asking Smart Questions FAQ - How To Put Your Code In Code Tags
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Thread join() method