Interface ListenableFuture<V>

  • Type Parameters:
    V - the type of the result of the computation
    All Superinterfaces:
    java.util.concurrent.Future<V>

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

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      void addDoneListener​(java.lang.Runnable listener)
      Adds a listener to run on successful or unsuccessful completion of the asynchronous computation.
      boolean removeDoneListener​(java.lang.Runnable listener)
      Removes a done listener so that it will not be called when the computation completes.
      • Methods inherited from interface java.util.concurrent.Future

        cancel, get, get, isCancelled, isDone
    • Method Detail

      • addDoneListener

        void addDoneListener​(java.lang.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:
        java.lang.IllegalArgumentException - if listener is null
        Since:
        100.0.0
      • removeDoneListener

        boolean removeDoneListener​(java.lang.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