-
Book Overview & Buying
-
Table Of Contents
Mastering Concurrency Programming with Java 8
By :
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 result.
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 the generic type parameter of the Callable interface. To get the result returned by the task, the executor will return you 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 to it, and personalize the executor to adapt it to your needs. In this chapter, you will learn how to work with tasks...