• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Thread join method?

 
Ashish Anant Patil
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 15356
39
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Shahir Deo
Ranch Hand
Posts: 80
Hibernate Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Nancy Avent
Ranch Hand
Posts: 94
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic