Interface Scheduler

  • All Superinterfaces:
    Executor

    public interface Scheduler
    extends Executor
    Scheduler to run timer tasks, e.g. for expiry and refresh. A cache with expiry typically inserts one task in the scheduler to execute pending expiry or refresh jobs. A task is usually not executed more often then one second per cache Cache2kBuilder.timerLag(long, TimeUnit) ). Per task execution all pending actions per cache are processed. The execution of tasks should run on a different executor to improve scalability when many caches with expiry run in one runtime.

    An instance may implement AutoCloseable if resources need to be cleaned up.

    Author:
    Jens Wilke
    • Method Detail

      • schedule

        void schedule​(Runnable runnable,
                      long delayMillis)
        Schedule the task to be run after a given delay. This uses always millisecond resolution. A negative or zero duration means immediate execution is requested.
        Throws:
        RejectedExecutionException - if scheduler was closed
      • execute

        void execute​(Runnable command)
        Run a task immediately, usually via the common ForkJoinPool. This is used for tasks that are due in the past and should execute as soon as possible. This is intended to run on the same executor then the scheduled tasks.
        Specified by:
        execute in interface Executor