Advanced characteristics of executors
An executor is a class that allows programmers to execute concurrent tasks without being worried about the creation and management of threads. Programmers create Runnable
objects and send them to the executor that creates and manages the necessary threads to execute those tasks. In Chapter 3, Managing Lots of Threads - Executors, we introduced the basic characteristics of the executor framework:
- How to create an executor and the different options we have when we create one
- How to send a concurrent task to an executor
- How to control the resources used by the executor
- How the executor, internally, uses a pool of threads to optimize the performance of the application
However, executors can give you many more options to make them a powerful mechanism for your concurrent application.
Cancellation of tasks
You can cancel the execution of a task after you send it to an executor. When you send a Runnable
object to an executor using the submit()
method, it returns an...