Class CompletableFuture<T>

java.lang.Object
java.util.concurrent.CompletableFuture<T>
All Implemented Interfaces:
CompletionStage<T>, Future<T>

public class CompletableFuture<T> extends Object implements Future<T>, CompletionStage<T>

java.util.concurrent.CompletableFuture for the Codename One runtime.

A stage completes on the thread that completed the one before it, as in the JDK. The ...Async methods without an executor run on a pool of daemon threads -- there is no fork-join pool here -- and never on the UI thread; a continuation that touches the user interface passes an executor that calls Display.callSerially, or calls it itself.

The class is safe to use from several threads at once: its state is kept in atomics, and every dependent action runs exactly once.

get() and join() on the UI thread wait through JdkHost.blockUi, which on a device is Display.invokeAndBlock: events keep being dispatched.

Exceptions travel as in the JDK: a stage that depends on a failed one fails with a CompletionException whose cause is the original; get() reports that cause in an ExecutionException, join() throws the CompletionException, and both throw CancellationException after cancel.

Not provided: obtrudeValue, obtrudeException, getNumberOfDependents, delayedExecutor and state().