• 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:
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Ron McLeod
  • Tim Cooke
Sheriffs:
  • Devaka Cooray
  • paul wheaton
  • Mark Herschberg
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Frits Walraven
  • Jj Roberts
Bartenders:
  • Carey Brown
  • salvin francis
  • Piet Souris

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
 
I need a new interior decorator. This tiny ad just painted every room in my house purple.
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic