Class NotifyingFutureTask

  • All Implemented Interfaces:
    Runnable, Future<Void>, RunnableFuture<Void>

    public class NotifyingFutureTask
    extends FutureTask<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 Detail

      • NotifyingFutureTask

        public NotifyingFutureTask​(Callable<Void> callable)
      • NotifyingFutureTask

        public NotifyingFutureTask​(Runnable task)
    • Method Detail

      • onComplete

        public void onComplete​(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