Interface Scheduler

  • Functional Interface:
    This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

    @FunctionalInterface
    public interface Scheduler
    A scheduler that submits a task to an executor after a given delay.
    • Method Detail

      • schedule

        Future<?> schedule​(Executor executor,
                           Runnable command,
                           long delay,
                           TimeUnit unit)
        Returns a future that will submit the task to the given executor after the given delay.
        Parameters:
        executor - the executor to run the task
        command - the runnable task to schedule
        delay - how long to delay, in units of unit
        unit - a TimeUnit determining how to interpret the delay parameter
        Returns:
        a scheduled future representing pending submission of the task
      • disabledScheduler

        static Scheduler disabledScheduler()
        Returns a scheduler that always returns a successfully completed future.
        Returns:
        a scheduler that always returns a successfully completed future
      • guardedScheduler

        static Scheduler guardedScheduler​(Scheduler scheduler)
        Returns a scheduler that suppresses and logs any exception thrown by the delegate scheduler.
        Parameters:
        scheduler - the scheduler to delegate to
        Returns:
        a scheduler that suppresses and logs any exception thrown by the delegate