This week's giveaway is in the Spring forum.
We're giving away four copies of Microservices Testing (Live Project) and have Chris Love & Andres Sacco on-line!
See this thread for details.
Win a copy of Microservices Testing (Live Project) this week in the Spring forum!
  • 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Liutauras Vilda
  • Henry Wong
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Mikalai Zaikin
  • Himai Minh

Threads join() method

 
Ranch Hand
Posts: 366
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
According to join method documentation,

Waits at most millis milliseconds for this thread to die. A timeout of 0 means to wait forever


What does this exactly mean ? After the time elapses, does the join method kill the thread on which it has joined? or it exits the main thread ?
I am quite confused because I have written a small code in which after the timeout happens, the thread on which join is called is still running.
Can someone kindly provide some explanation on this
Thanks in advance
Sri
 
author
Posts: 3252
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Sri Sri:
[...] After the time elapses, does the join method kill the thread on which it has joined? or it exits the main thread ?

Neither. After the time elapses, the thread of control returns from the join() method without any action taken. You can call isAlive() on the thread to find out if join() has returned because the thread stopped, or whether it returned because the timeout had expired.
- Peter
 
Sridhar Srikanthan
Ranch Hand
Posts: 366
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Peter,
That helps
Sri
 
reply
    Bookmark Topic Watch Topic
  • New Topic