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'sgetmethod
- 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 aListenableFutureTaskthat will, upon running, execute the givenRunnable, and arrange thatFutureTask.get()will return the given result on successful completion.ListenableFutureTask(Callable<T> callable) Create a newListenableFutureTaskthat will, upon running, execute the givenCallable. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddCallback(ListenableFutureCallback<? super T> callback) Register the givenListenableFutureCallback.voidaddCallback(SuccessCallback<? super T> successCallback, FailureCallback failureCallback) Java 8 lambda-friendly alternative with success and failure callbacks.Expose thisListenableFutureas a JDKCompletableFuture.protected voiddone()Methods inherited from class java.util.concurrent.FutureTask
cancel, get, get, isCancelled, isDone, run, runAndReset, set, setException, toString
-
Constructor Details
-
ListenableFutureTask
Create a newListenableFutureTaskthat will, upon running, execute the givenCallable.- Parameters:
callable- the callable task
-
ListenableFutureTask
Create aListenableFutureTaskthat 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:ListenableFutureRegister the givenListenableFutureCallback.- Specified by:
addCallbackin interfaceListenableFuture<T>- Parameters:
callback- the callback to register
-
addCallback
public void addCallback(SuccessCallback<? super T> successCallback, FailureCallback failureCallback) Description copied from interface:ListenableFutureJava 8 lambda-friendly alternative with success and failure callbacks.- Specified by:
addCallbackin interfaceListenableFuture<T>- Parameters:
successCallback- the success callbackfailureCallback- the failure callback
-
completable
Description copied from interface:ListenableFutureExpose thisListenableFutureas a JDKCompletableFuture.- Specified by:
completablein interfaceListenableFuture<T>
-
done
protected void done()- Overrides:
donein classFutureTask<T>
-