Class DelegatingScheduler

  • All Implemented Interfaces:
    Scheduler

    public final class DelegatingScheduler
    extends java.lang.Object
    implements Scheduler
    A Scheduler implementation that schedules delays on an internal, common ScheduledExecutorService and executes tasks on either a provided ExecutorService, ForkJoinPool.commonPool(), or an internal ForkJoinPool instance. If no ExecutorService is supplied, the ForkJoinPool.commonPool() will be used, unless the common pool's parallelism is 1, then an internal ForkJoinPool with parallelism of 2 will be created and used.

    Supports cancellation and interruption of ForkJoinPool tasks.

    • Field Detail

      • FORK_JOIN_POOL

        private static volatile java.util.concurrent.ForkJoinPool FORK_JOIN_POOL
      • DELAYER

        private static volatile java.util.concurrent.ScheduledThreadPoolExecutor DELAYER
      • executorService

        private final java.util.concurrent.ExecutorService executorService
    • Constructor Detail

      • DelegatingScheduler

        private DelegatingScheduler()
      • DelegatingScheduler

        public DelegatingScheduler​(java.util.concurrent.ExecutorService executor)
    • Method Detail

      • delayer

        private static java.util.concurrent.ScheduledExecutorService delayer()
      • executorService

        private java.util.concurrent.ExecutorService executorService()
      • schedule

        public java.util.concurrent.ScheduledFuture<?> schedule​(java.util.concurrent.Callable<?> callable,
                                                                long delay,
                                                                java.util.concurrent.TimeUnit unit)
        Description copied from interface: Scheduler
        Schedules the callable to be called after the delay for the unit.
        Specified by:
        schedule in interface Scheduler