CompletableFuture in Support of Asynchronous Processing
The java.util.concurrent.CompletableFuture<T>
class was first introduced in Java 8. It is the next level of asynchronous call control over java.util.concurrent.Future<T>
interface. It actually implements Future
, as well as java.util.concurrent.CompletionStage<T>
. In Java 9, CompletableFuture
was enhanced by adding new factory methods, support for delays and timeouts, and improved subclassing--we will discuss these features in more details in the sections to follow. But first, let's have an overview of the CompletableFuture
API.
The CompletableFuture API Overview
The CompletableFuture
API consists of more than 70 methods, 38 of which are implementations of the CompletionStage
interface, and five are the implementations of Future
. Because the CompletableFuture
class implements the Future
interface, it can be treated as Future
and will not break the existing functionality based on the Future
API.
So, the bulk of the API comes...