Getting ready

You should read the Creating, running, and setting the characteristics of a thread recipe in Chapter 1, Thread Management, to learn the basic mechanism of thread creation in Java. You can compare both the mechanisms and select one, depending on the problem.

The example of this recipe has been implemented using the Eclipse IDE. If you use Eclipse or a different IDE, such as NetBeans, open it and create a new Java project.

Get Java 9 Concurrency Cookbook - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.