Introduced in Java 8 (2014).
A java.util.concurrent.CompletionState
interface represents an asynchronous or synchronous computation task.
This task performs an action or computes a value when another CompletionStage completes.
There are a few classifications that are identifiable via patterns in the method’s name.
Types of computation determined by method name pattern
Pattern in method name | Description |
---|---|
|
Function computation on result or value of the CompletionStage |
|
Consumer computation on result or value of the CompletionStage |
|
Runnable computation |
Actions performed determined by method name pattern
Pattern in method name | Description |
---|---|
|
Similar to apply, returns a new CompletionStage after the completion of the current one, thus allowing pipelines |
|
Combine results of two completion stages into a BiFunction and returns a new CompletionStage |
|
handle any exception via a Function that returns a CompletedStage, successful completion is returned as the value of CompletionStage |
|
handle either successful result or exception passed as a BiConsumer and returns a new CompletionStage |
|
handle either successful result or exception passed as a BiFunction and returns a new CompletionStage |
Synchronicity of the stage is either Sync or Async
Pattern in method name | Description |
---|---|
<nothing> |
synchronous |
|
asynchronous |