T
- the result type returned by this Future's get
methodpublic class ListenableFutureTask<T> extends FutureTask<T> implements ListenableFuture<T>
FutureTask
that implements ListenableFuture
.Constructor and Description |
---|
ListenableFutureTask(Callable<T> callable)
Create a new
ListenableFutureTask that will, upon running,
execute the given Callable . |
ListenableFutureTask(Runnable runnable,
T result)
Create a
ListenableFutureTask that will, upon running,
execute the given Runnable , and arrange that FutureTask.get()
will return the given result on successful completion. |
Modifier and Type | Method and Description |
---|---|
void |
addCallback(ListenableFutureCallback<? super T> callback)
Register the given
ListenableFutureCallback . |
void |
addCallback(SuccessCallback<? super T> successCallback,
FailureCallback failureCallback)
Java 8 lambda-friendly alternative with success and failure callbacks.
|
CompletableFuture<T> |
completable()
Expose this
ListenableFuture as a JDK CompletableFuture . |
protected void |
done() |
cancel, get, get, isCancelled, isDone, run, runAndReset, set, setException
public ListenableFutureTask(Callable<T> callable)
ListenableFutureTask
that will, upon running,
execute the given Callable
.callable
- the callable taskpublic ListenableFutureTask(Runnable runnable, @Nullable T result)
ListenableFutureTask
that will, upon running,
execute the given Runnable
, and arrange that FutureTask.get()
will return the given result on successful completion.runnable
- the runnable taskresult
- the result to return on successful completionpublic void addCallback(ListenableFutureCallback<? super T> callback)
ListenableFuture
ListenableFutureCallback
.addCallback
in interface ListenableFuture<T>
callback
- the callback to registerpublic void addCallback(SuccessCallback<? super T> successCallback, FailureCallback failureCallback)
ListenableFuture
addCallback
in interface ListenableFuture<T>
successCallback
- the success callbackfailureCallback
- the failure callbackpublic CompletableFuture<T> completable()
ListenableFuture
ListenableFuture
as a JDK CompletableFuture
.completable
in interface ListenableFuture<T>
protected void done()
done
in class FutureTask<T>