This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
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


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Thread join method?" Watch "Thread join method?" New topic
Author

Thread join method?

Ashish Anant Patil
Greenhorn

Joined: Mar 17, 2013
Posts: 7
P.S.V.M{
Thread t=new Thread();
t.join;

please correct me if Iam wrong....It Means join Main behind tread t1...right???

and can we join any other thread behind t1...for say t2....and how???
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14074
    
  16

Did you read the API documentation for Thread.join()?

t.join(); means that the thread that you are making this call from (the main thread, for example) waits for thread t to stop.


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
Shahir Deo
Ranch Hand

Joined: Mar 19, 2013
Posts: 78

t.join() will run thread t and put all other threads in wait after it finishes the process the other threads can now run. InterruptedException is the exception which is thrown if thread t is interrupted by any other threads.


Knowledge enlivens the soul.
Nancy Avent
Ranch Hand

Joined: Feb 23, 2013
Posts: 94
Shahir Deo wrote:t.join() will run thread t and put all other threads in wait after it finishes the process the other threads can now run. InterruptedException is the exception which is thrown if thread t is interrupted by any other threads.


I think, the description provided you is confusing and incorrect.

Due to statement t.join(), the main thread will wait till thread t completes.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Thread join method?
 
Similar Threads
join() start() run()
Tharead start() /join()
Threads
regding Thread.join
Join() method in Java