CompletableFuture API enhancements

The CompleteableFuture<T> class is part of the java.util.concurrent package. The class extends the Object class and implements the Future<T> and CompletionStage<T> interfaces. This class is used to annotate threads that can be completed. We can use the CompletableFuture class to represent a future result. When the complete method is used, that future result can be completed.

It is important to realize that if multiple threads attempt to simultaneously complete (finish or cancel), all but one will fail. Let's look at the class and then look at the enhancements.

Get Java 9: Building Robust Modular Applications now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.