Thejoin
method allows one thread to wait for the completion of another. Ift
is aThread
object whose thread is currently executing,causes the current thread to pause execution untilt.join();t
's thread terminates. Overloads ofjoin
allow the programmer to specify a waiting period. However, as withsleep
,join
is dependent on the OS for timing, so you should not assume thatjoin
will wait exactly as long as you specify.Like
sleep
,join
responds to an interrupt by exiting with anInterruptedException
.