O'Reilly logo

Java™ Phrasebook by Timothy Fisher

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Waiting For a Thread to Complete

Thread t = new Thread(MyThread);
											t.start();
											// do some other processing
											t.join();
											// continues after thread t completes

It might be the case that you want one thread of execution to wait for another thread to complete before continuing with the current thread. Joining threads is a common method of causing one thread to wait for the completion of another thread. For example, in this phrase, we start thread t from within the thread that is executing these lines of code. We then, in most cases, do some additional processing and call the join() method on the thread object when we want to stop execution of this thread and wait for the thread t to complete. Once thread t completes, execution will continue to the statements ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required