public interface Promise<V> extends Future<V>
Futurewhich is writable.
Promise can be completed or canceled, cancellation is performed by the
Once a computation has completed, the computation cannot be cancelled. If you would like to use a
for the sake of cancellability but not provide a usable result, you can declare type+s of the form
Promise<?> and return
null as a result of the underlying task.
|Modifier and Type||Method and Description|
Attempts to cancel execution of this task.
Set the value to this promise and mark it completed if set successfully.
Marks this promise as a failure and notifies all listeners.
boolean cancel(boolean mayInterruptIfRunning)
cancelis called, this task should never run. If the task has already started, then the
mayInterruptIfRunningparameter determines whether the thread executing this task should be interrupted in an attempt to stop the task.
trueif the thread executing this task should be interrupted; otherwise, in-progress tasks are allowed to complete
falseif the task could not be cancelled, typically because it has already completed normally;
boolean set(V value)
boolean setFailure(Throwable cause)
cause- the cause
Copyright © 2017–2019 OpenMessaging. All rights reserved.