• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Junilu Lacar
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Ganesh Patekar
  • Tim Moores
  • Pete Letkeman
  • Stephan van Hulst
Bartenders:
  • Carey Brown
  • Tim Holloway
  • Joe Ess

Thread join method?  RSS feed

 
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???
 
Java Cowboy
Sheriff
Posts: 16084
88
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.
 
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.
 
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
Boost this thread!