Thread.join

The method that makes the current thread wait until another thread has finished.

In more detail

Joining gives a stable order: after join returns, the worker's work is complete and its results are safe to use. Without it, the main thread might finish before the worker prints. CompletableFuture also has a join method that waits for its result.

Example

worker.start(); worker.join();

Related terms

Taught in

References

Certification courses