Google News
logo
Java Multithreading - Interview Questions
What does join() method in java?
The join() method waits for a thread to die. In other words, it causes the currently running threads to stop executing until the thread it joins with completes its task. Join method is overloaded in Thread class in the following ways.
 
* public void join()throws InterruptedException
* public void join(long milliseconds)throws InterruptedException

join() : When the join() method is invoked, the current thread stops its execution and the thread goes into the wait state. The current thread remains in the wait state until the thread on which the join() method is invoked has achieved its dead state. If interruption of the thread occurs, then it throws the InterruptedException.
 
Syntax :
public final void join() throws InterruptedException
Advertisement