Interface ListenableFuture<T>

Type Parameters:
T - the result type returned by this Future's get method
All Superinterfaces:
Future<T>
All Known Implementing Classes:
AsyncResult, CompletableToListenableFutureAdapter, ListenableFutureAdapter, ListenableFutureTask, MonoToListenableFutureAdapter, SettableListenableFuture

public interface ListenableFuture<T> extends Future<T>
Extend Future with the capability to accept completion callbacks. If the future has completed when the callback is added, the callback is triggered immediately.

Inspired by com.google.common.util.concurrent.ListenableFuture.

Since:
4.0
Author:
Arjen Poutsma, Sebastien Deleuze, Juergen Hoeller
  • Method Details

    • addCallback

      void addCallback(ListenableFutureCallback<? super T> callback)
      Register the given ListenableFutureCallback.
      Parameters:
      callback - the callback to register
    • addCallback

      void addCallback(SuccessCallback<? super T> successCallback, FailureCallback failureCallback)
      Java 8 lambda-friendly alternative with success and failure callbacks.
      Parameters:
      successCallback - the success callback
      failureCallback - the failure callback
      Since:
      4.1
    • completable

      default CompletableFuture<T> completable()
      Expose this ListenableFuture as a JDK CompletableFuture.
      Since:
      5.0