V- The result type returned by the future.
public interface ListenableFuture<V> extends Future<V>
Future that allows asynchronous notifications.
This kind of future can be used to be notified when the result is available, thus removing the need for a blocking thread that waits on the result.
|Modifier and Type||Method and Description|
Registers a completion listener with this future.
Removes the registration of a completion listener with this future.
boolean addCompletionListener(FutureCompletionListener<? super V> listener)
Registers a completion listener with this future. This listener is
notified when the future completes (
true). If the future completes before the listener is
registered, the listener is notified immediately while being added.
If the specified listener is already registered with this future, no
action is taken and this method returns
Important note: Typically, the listener is executed by
the thread that sets the future's value. For this reason, it is important
that the listener does not block or perform any long-running operations.
Instead, the listener should delegate any such operation to a different
thread (e.g. using an
Executor). Any violation of this rule might
result in unexpected or unpredictable behavior. In particular, a blocking
listener might cause a dead-lock, which results in the whole application
being stalled indefinitely.
listener- listener to be registered with this future.
trueif the listener has been added,
falseif it has already been added earlier.
boolean removeCompletionListener(FutureCompletionListener<? super V> listener)
Removes the registration of a completion listener with this future. After removing, the listener is not going to be notified when the future completes.
If the specified listener is not currently registered with this future,
no action is taken and this method returns
listener- listener to be unregistered from this future.
trueif the listener has been removed,
falseif it has already been removed earlier of if has never been added.
Copyright © 2014–2017 aquenos GmbH. All rights reserved.