wood burning stoves 2.0*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Thread.join Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Thread.join" Watch "Thread.join" New topic
Author

Thread.join

Vishal Arora
Greenhorn

Joined: Jul 29, 2005
Posts: 9
Please let me know whethere it is tru or not:
A timeout of of zero will allow Thread.join to wait forever if necessary.

If it is true then how.
marc weber
Sheriff

Joined: Aug 31, 2004
Posts: 11343

According to the API, "A timeout of 0 means to wait forever."


"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
sscce.org
Sergei Iakhnin
Ranch Hand

Joined: Nov 09, 2004
Posts: 53
It is true. Not sure what you mean by "how". What specifically about how it's possible interests you?


SCJP 1.4, SCWCD 1.4
Joe Sondow
Ranch Hand

Joined: Apr 10, 2005
Posts: 195
Here's how. The code for Thread.join(long millis) is as follows:



SCJA 1.0 (98%), SCJP 1.4 (98%)
shyam ramineni
Ranch Hand

Joined: Jul 08, 2005
Posts: 43
Hi All,

From the code I understand that if we call t2.join(0) in thread t1, then, t1 will wait forever till t2 completes.
t1 will start if thread t2 has finished.

am I right.

Shyam Ramineni


<a href="http://hyderabaditeducation.com" target="_blank" rel="nofollow">http://hyderabaditeducation.com</a>
Joe Sondow
Ranch Hand

Joined: Apr 10, 2005
Posts: 195
Originally posted by shyam ramineni:
Hi All,

From the code I understand that if we call t2.join(0) in thread t1, then, t1 will wait forever till t2 completes.
t1 will start if thread t2 has finished.

am I right.

Shyam Ramineni


Almost right. Your first sentence is correct. t1 will wait, potentially forever, until t2 completes. Your second sentence is not quite right, but it's close. t1 won't necessarily start up again if t2 has finished, but t1 will become runnable when t2 finishes, so the thread scheduler can then resume the execution of t1 when the scheduler chooses to do so.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Thread.join
 
Similar Threads
how to end all threads before ending main
Thread problem
Threads
Pause program until pop-up window is displayed?
how to know any one thread is alive while running mulple thread?