Class NotifyingFutureTask

  • All Implemented Interfaces:
    java.lang.Runnable, java.util.concurrent.Future<java.lang.Void>, java.util.concurrent.RunnableFuture<java.lang.Void>

    public class NotifyingFutureTask
    extends java.util.concurrent.FutureTask<java.lang.Void>
    A Future that accepts completion listener. The listener is invoked once the future's computation is complete. If the computation has already completed when the listener is added, the listener will execute immediately.

    Listener is invoked synchronously on the same thread which is used to executed the Future

    • Constructor Summary

      Constructors 
      Constructor Description
      NotifyingFutureTask​(java.lang.Runnable task)  
      NotifyingFutureTask​(java.util.concurrent.Callable<java.lang.Void> callable)  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      static NotifyingFutureTask completed()  
      void onComplete​(java.lang.Runnable onComplete)
      Set the on complete handler.
      • Methods inherited from class java.util.concurrent.FutureTask

        cancel, get, get, isCancelled, isDone, run, toString
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • NotifyingFutureTask

        public NotifyingFutureTask​(java.util.concurrent.Callable<java.lang.Void> callable)
      • NotifyingFutureTask

        public NotifyingFutureTask​(java.lang.Runnable task)
    • Method Detail

      • onComplete

        public void onComplete​(java.lang.Runnable onComplete)
        Set the on complete handler. The handler will run exactly once after the task terminated. If the task has already terminated at the time of this method call the handler will execute immediately.

        Note: there is no guarantee to which handler will run when the method is called multiple times with different arguments.

        Parameters:
        onComplete - listener to invoke upon completion