接口 ListenableFuture<T>

类型参数:
T - the result type returned by this Future's get method
所有超级接口:
Future<T>
所有已知实现类:
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.

in favor of CompletableFuture

从以下版本开始:
4.0
作者:
Arjen Poutsma, Sebastien Deleuze, Harry Yang, Juergen Hoeller
  • 方法详细资料

    • addCallback

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

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

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