Added in API level 24
Summary:
Methods
CompletionStage
public
interface
CompletionStage
| java.util.concurrent.CompletionStage<T> |
A stage of a possibly asynchronous computation, that performs an action or computes a value when another CompletionStage completes. A stage completes upon termination of its computation, but this may in turn trigger other dependent stages. The functionality defined in this interface takes only a few basic forms, which expand out to a larger set of methods to capture a range of usage styles:
- The computation performed by a stage may be expressed as a
Function, Consumer, or Runnable (using methods with names including
apply, accept, or run, respectively)
depending on whether it requires arguments and/or produces results.
For example:
stage.thenApply(x -> square(x)) .thenAccept(x -> System.out.print(x)) .thenRun(()