Class SingletonTask


  • public final class SingletonTask
    extends Object
    A task that can be scheduled for a run and is guaranteed to never run concurrently, regardless of the thread pool it's submitted to.
    • Method Detail

      • ensureScheduled

        public void ensureScheduled()
        Ensures the task will run in the future.
        • If the task is neither scheduled nor running, this schedules the task for execution.
        • If the task is already scheduled but not running, this does nothing: the task remains scheduled.
        • If the task is running: the task execution continues and will trigger re-scheduling when it finishes.
      • completion

        public CompletableFuture<?> completion()
        Returns:
        A future that completes when all works submitted to the executor so far are completely executed. Works submitted to the executor after entering this method may delay the wait.
      • stop

        public void stop()
        Stop the task.

        Callers must call this as the very last method on this object; any concurrent call may lead to unpredictable results.