From oracle documentation page on Joins
The
join
method allows one thread to wait for the completion of another.
If t1 is a Thread
object whose thread is currently executing,
t1.join() : causes the current thread to pause execution until t1's thread terminates.
If t2 is a Thread
object whose thread is currently executing,
t2.join(); causes the current thread to pause execution until t2's thread terminates.
join
API is low level API, which has been introduced in earlier versions of java. Lot of things have been changed over a period of time (especially with jdk 1.5 release) on concurrency front.
You can achieve the same with java.util.concurrent API. Some of the examples are
ExecutorService
Executors
(since java 8)Refer to related SE questions: