aspose file tools
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes join() method Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Reply Bookmark "join() method" Watch "join() method" New topic
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!
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: join() method
 
Similar Threads
join() method in Thread doesn't work as expected
How can i start multiple threads ??
Thread dependency
Explain Join() method of Thread
Clarify Use of the join method