O'Reilly logo

Java 9 Cookbook by Nick Samoylov, Mohamed Sanaulla

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

There's more...

There are two other important methods that allow threads to cooperate. First is the join() method that allows the current thread to wait until another thread is terminated. Overloaded versions of join() accept the parameters that define how long the thread has to wait before it could do something else. 

The setDaemon() method terminates the thread automatically after all the non-daemon threads are terminated. Usually, it is used for background and supporting processes.

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