File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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

Thread join() method

Shiva Mohan
Ranch Hand

Joined: Jan 05, 2006
Posts: 481

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.


Asking Smart Questions FAQ - How To Put Your Code In Code Tags
I agree. Here's the link:
subject: Thread join() method
It's not a secret anymore!