join()
methods block the calling thread
until the thread whose join()
method is invoked dies.
public final void join() throws InterruptedException
public final void join(long milliseconds) throws InterruptedException
public final void join(long milliseconds, int nanoseconds)
throws InterruptedException
For example, t.join()
waits for the Thread t
to finish before continuing. t.join(1000)
waits at most one second for t
to finish before continuing.You would generally use this when one thread depends on another, for example for a file to be read or an image to be loaded from the net.