Interface ListenableFuture<V>

Type Parameters:
V - the type of the result of the computation
All Superinterfaces:
Future<V>

public interface ListenableFuture<V> extends Future<V>
A specialized Future that allows listeners to be set to run when the asynchronous computation is done.
Since:
100.0.0
  • Method Details

    • addDoneListener

      void addDoneListener(Runnable listener)
      Adds a listener to run on successful or unsuccessful completion of the asynchronous computation. The listener will run immediately if the computation is already complete when this method is called.

      Adding this listener on the UI thread will cause it to be invoked on the UI thread, otherwise it is not guaranteed on which thread the listener is invoked.

      Parameters:
      listener - a Runnable to run when the computation is done
      Throws:
      IllegalArgumentException - if listener is null
      Since:
      100.0.0
    • removeDoneListener

      boolean removeDoneListener(Runnable listener)
      Removes a done listener so that it will not be called when the computation completes.
      Parameters:
      listener - the listener to be removed
      Returns:
      true if the listener was removed, otherwise false
      Since:
      100.0.0
    • toCompletableFuture

      CompletableFuture<V> toCompletableFuture()
      Returns a CompletableFuture wrapping for this object.
      Returns:
      the completable future
      Since:
      200.2.0