Class details

The CompletableFuture<T> class has one nested class that marks asynchronous tasks:

public static interface CompletableFuture.AsynchronousCompletionTask

The constructor for the CompletableFuture<T> class has to be in sync with the provided constructor signature. It also must not take any arguments. The class has the following methods, which are organized by what they return:

Returns CompletionStage:

  • public CompletableFuture<Void> acceptEither(CompletionStage<? extends T> other, Consumer<? super T> action)
  • public CompletableFuture<Void> acceptEitherAsync(CompletionStage<? extends T> other, Consumer<? super T> action)
  • public CompletableFuture<Void> acceptEitherAsync(CompletionStage<? extends T> other, Consumer<? super T> action, ...

Get Mastering Java 11 - Second Edition 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.