O'Reilly logo

Java 9 Concurrency Cookbook - Second Edition by Javier Fernández González

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

Delegating the management of threads to executors

Before Java 5, the Java Concurrency API, when we wanted to implement a concurrent application, we had to manage the threads by ourselves. First we used to implement the Runnable interface or an extension of the Thread class. Then, we used to create a thread object and start its execution using its start() method. We also had to control its status to know whether the thread had finished its execution or was still running.

In Java version 5, the concept of executor as a provider of a pool of execution threads appeared. This mechanism, implemented by the Executor and ExecutorService interfaces and the ThreadPoolExecutor and ScheduledThreadPoolExecutor classes, allows you to concentrate only on ...

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