Valhalla Legends Forums Archive | Java Programming | Question about Thread.join()

AuthorMessageTime
DarkOne
What exactly does this method do? Is it used in connection with synchronization in some way? I'm uderstanding the use of this method in two ways:

1) Actually waits for a thread started before (Thread.start() is invoked on a thread before another thread) and executed when that thread is done executing.

2) Waits for an oppertunity to safely 'interrupt' the execution of the previous thread and begins executing for some interval of time.

Sorry if my wording is a bit confusing.
April 16, 2004, 6:05 AM
Tuberload
It allows a thread to wait untill another thread is done executing. So say you want a specific thread to always be the last thread executed when a program exits. You would have it call the join() method on all the other running threads, and it would then wait for them to finish.
April 16, 2004, 7:45 AM
iago
http://java.sun.com/j2se/1.4.2/docs/api/java/lang/Thread.html#join()

Basically, what Tuberload said, "Waits for the thread to die"
April 16, 2004, 11:49 AM
Tuberload
[quote author=iago link=board=34;threadid=6323;start=0#msg55401 date=1082116192]
http://java.sun.com/j2se/1.4.2/docs/api/java/lang/Thread.html#join()

Basically, what Tuberload said, "Waits for the thread to die"
[/quote]

Ah, never thought to point him to the documentation. :)
April 16, 2004, 6:57 PM
DarkOne
[quote author=Tuberload link=board=34;threadid=6323;start=0#msg55433 date=1082141859]
[quote author=iago link=board=34;threadid=6323;start=0#msg55401 date=1082116192]
http://java.sun.com/j2se/1.4.2/docs/api/java/lang/Thread.html#join()

Basically, what Tuberload said, "Waits for the thread to die"
[/quote]

Ah, never thought to point him to the documentation. :)
[/quote]

No need to point me there. I use the documentation whenever necessary, I read there first, but I found their description of the join() function a bit unclear.

Thanks for the replies iago and tuberload.
April 17, 2004, 1:46 AM

Search