org.springframework.util.concurrent

## Class ListenableFutureTask<T>

- java.lang.Object
- - java.util.concurrent.FutureTask<T>
  - - org.springframework.util.concurrent.ListenableFutureTask<T>

- All Implemented Interfaces:
    Runnable, Future<T>, RunnableFuture<T>, ListenableFuture<T>

      public class ListenableFutureTask<T>
      extends FutureTask<T>
      implements ListenableFuture<T>

  Extension of `FutureTask` that implements `ListenableFuture`.
  Since:
    4.0
  Author:
    Arjen Poutsma

- - ### Constructor Summary

    Constructors
    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.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `addCallback(ListenableFutureCallback<? super T> callback)` Registers the given callback to this `ListenableFuture`.
    `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(Callable<T> callable)

      Create a new `ListenableFutureTask` that will, upon running, execute the given `Callable`.
      Parameters:
        `callable` - the callable task

    - #### ListenableFutureTask

          public 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.
      Parameters:
        `runnable` - the runnable task
        `result` - the result to return on successful completion

  - ### Method Detail

    - #### addCallback

          public void addCallback(ListenableFutureCallback<? super T> callback)

      Description copied from interface: `ListenableFuture`
      Registers the given callback to this `ListenableFuture`. The callback will be triggered when this `Future` is complete or, if it is already complete, immediately.
      Specified by:
        `addCallback` in interface `ListenableFuture<T>`
      Parameters:
        `callback` - the callback to register

    - #### done

          protected final void done()

      Overrides:
        `done` in class `FutureTask<T>`