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 a lot 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 millis)
        Schedule a task to be run at the given time
        Parameters:
        millis - since epoch, provided by TimeReference.toMillis(long)
      • 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 executed as soon as possible. This is intended to run on the same executor then the scheduled tasks.
        Specified by:
        execute in interface Executor