The Java Tutorials have been written for JDK 8. Examples and practices described in this page don't take advantage of improvements introduced in later releases and might use technology no longer available.
See Java Language Changes for a summary of updated language features in Java SE 9 and subsequent releases.
See JDK Release Notes for information about new features, enhancements, and removed or deprecated options for all JDK releases.
The join
method allows one thread to wait for the completion of another. If t
is a Thread
object whose thread is currently executing,
t.join();
causes the current thread to pause execution until t
's thread terminates. Overloads of join
allow the programmer to specify a waiting period. However, as with sleep
, join
is dependent on the OS for timing, so you should not assume that join
will wait exactly as long as you specify.
Like sleep
, join
responds to an interrupt by exiting with an InterruptedException
.