| Author |
join() method
|
dennis zined
Ranch Hand
Joined: Mar 07, 2003
Posts: 330
|
|
Hi all. In the code snippet below, how can I get t2 join t1? thanks.
|
SCJP 1.4<br />SCWCD 1.4
|
 |
Vad Fogel
Ranch Hand
Joined: Aug 25, 2003
Posts: 504
|
|
Hi Dennis, if I get your question right, a possible solution with minor modifications can look like this: Hope this helps.  [ December 24, 2003: Message edited by: Vad Fogel ]
|
 |
venkatesh rajmendram
Ranch Hand
Joined: Dec 05, 2000
Posts: 130
|
|
Hi, The code looks good, but just one thing that poped into my mind... What if t2 never gets chance to run before t1, meaning there won't be actual join... ? or what if t1 will never get chance to run....and t1 goes ahead and finishes.... I might not sure but how about this code ... Just that t2 starts t1 and joins itself... Thanks Venkatesh
|
SCJP 1.4, SCWCD<p>Ours is a world where people don't know what they want and are willing to go through hell to get it.<br /> - Don Marquis
|
 |
Vad Fogel
Ranch Hand
Joined: Aug 25, 2003
Posts: 504
|
|
If a call to the thread's isAlive() method returns false, you can still join a currently executing thread to it. isAlive() returns false if a thread hasn't been started or its run() has completed. In this event, t.join() returns immediately to allow the current thread to continue executing. [ December 24, 2003: Message edited by: Vad Fogel ]
|
 |
dennis zined
Ranch Hand
Joined: Mar 07, 2003
Posts: 330
|
|
|
Thanks Vad, Venkatesh. I love this place!
|
 |
 |
|
|
subject: join() method
|
|
|