Contact Us

[email protected]

A thread can invoke the overloaded method join() (from the Thread class) on another thread in order to wait for the other thread to complete its execution before continuing—that is, the first thread waits for the second thread to join it after completion.

A running thread t1 invokes the method join() on a thread t2. The join() call has no effect if thread t2 has already completed. If thread t2 is still alive, thread t1 transits to one of the two waiting states. Depending on whether a timeout was specified or not in the call to the join() method, a call to the getState() method on thread t1 while it is waiting for join completion will return the value Thread.State.TIMED-_WAITING or Thread.State.WAITING, respectively.