Class ListenableFutureTask<T>
java.lang.Object
java.util.concurrent.FutureTask<T>
org.springframework.util.concurrent.ListenableFutureTask<T>
- Type Parameters:
T
- the result type returned by this Future'sget
method
- All Implemented Interfaces:
Runnable
,Future<T>
,RunnableFuture<T>
,ListenableFuture<T>
Extension of
FutureTask
that implements ListenableFuture
.- Since:
- 4.0
- Author:
- Arjen Poutsma
-
Constructor Summary
ConstructorsConstructorDescriptionListenableFutureTask
(Runnable runnable, T result) Create aListenableFutureTask
that will, upon running, execute the givenRunnable
, and arrange thatFutureTask.get()
will return the given result on successful completion.ListenableFutureTask
(Callable<T> callable) Create a newListenableFutureTask
that will, upon running, execute the givenCallable
. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addCallback
(ListenableFutureCallback<? super T> callback) Register the givenListenableFutureCallback
.void
addCallback
(SuccessCallback<? super T> successCallback, FailureCallback failureCallback) Java 8 lambda-friendly alternative with success and failure callbacks.Expose thisListenableFuture
as a JDKCompletableFuture
.protected void
done()
Methods inherited from class java.util.concurrent.FutureTask
cancel, get, get, isCancelled, isDone, run, runAndReset, set, setException, toString
-
Constructor Details
-
ListenableFutureTask
Create a newListenableFutureTask
that will, upon running, execute the givenCallable
.- Parameters:
callable
- the callable task
-
ListenableFutureTask
Create aListenableFutureTask
that will, upon running, execute the givenRunnable
, and arrange thatFutureTask.get()
will return the given result on successful completion.- Parameters:
runnable
- the runnable taskresult
- the result to return on successful completion
-
-
Method Details
-
addCallback
Description copied from interface:ListenableFuture
Register the givenListenableFutureCallback
.- Specified by:
addCallback
in interfaceListenableFuture<T>
- Parameters:
callback
- the callback to register
-
addCallback
public void addCallback(SuccessCallback<? super T> successCallback, FailureCallback failureCallback) Description copied from interface:ListenableFuture
Java 8 lambda-friendly alternative with success and failure callbacks.- Specified by:
addCallback
in interfaceListenableFuture<T>
- Parameters:
successCallback
- the success callbackfailureCallback
- the failure callback
-
completable
Description copied from interface:ListenableFuture
Expose thisListenableFuture
as a JDKCompletableFuture
.- Specified by:
completable
in interfaceListenableFuture<T>
-
done
protected void done()- Overrides:
done
in classFutureTask<T>
-