The Executor framework allows programmers to execute concurrent tasks without creating and managing threads. You create tasks and send them to the executor. It creates and manages the necessary threads.
In an executor, you can execute two kinds of tasks:
- Tasks based on the Runnable interface: These tasks implement the run() method that doesn't return any results.
- Tasks based on the Callable interface: These tasks implement the call() interface that returns an object as a result. The concrete type that will be returned by the call() method is specified by a generic type parameter of the Callable interface. To get the result returned by the task, the executor will return an implementation of the Future interface for every task.
In previous chapters, you learned how to create executors, send tasks based on the Runnable interface...