org.springframework.util.concurrent

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's get method
    All Implemented Interfaces:
    java.lang.Runnable, java.util.concurrent.Future<T>, java.util.concurrent.RunnableFuture<T>, ListenableFuture<T>


    public class ListenableFutureTask<T>
    extends java.util.concurrent.FutureTask<T>
    implements ListenableFuture<T>
    Extension of FutureTask that implements ListenableFuture.
    Since:
    4.0
    Author:
    Arjen Poutsma
    • Constructor Summary

      Constructors 
      Constructor and Description
      ListenableFutureTask(java.util.concurrent.Callable<T> callable)
      Create a new ListenableFutureTask that will, upon running, execute the given Callable.
      ListenableFutureTask(java.lang.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.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      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.
      java.util.concurrent.CompletableFuture<T> completable()
      Expose this ListenableFuture as a JDK CompletableFuture.
      protected void done() 
      • Methods inherited from class java.util.concurrent.FutureTask

        cancel, get, get, isCancelled, isDone, run, runAndReset, set, setException
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • Methods inherited from interface java.util.concurrent.Future

        cancel, get, get, isCancelled, isDone
    • Constructor Detail

      • ListenableFutureTask

        public ListenableFutureTask(java.util.concurrent.Callable<T> callable)
        Create a new ListenableFutureTask that will, upon running, execute the given Callable.
        Parameters:
        callable - the callable task
      • ListenableFutureTask

        public ListenableFutureTask(java.lang.Runnable runnable,
                                    @Nullable
                                    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.
        Parameters:
        runnable - the runnable task
        result - the result to return on successful completion