Class AdvancedScheduledThreadPoolExecutor

All Implemented Interfaces:
AdvancedScheduledExecutorService, jakarta.servlet.ServletContextListener, Executor, ExecutorService, ScheduledExecutorService, EventListener

class AdvancedScheduledThreadPoolExecutor extends ScheduledThreadPoolExecutor implements AdvancedScheduledExecutorService, jakarta.servlet.ServletContextListener
  • Constructor Details

    • AdvancedScheduledThreadPoolExecutor

      public AdvancedScheduledThreadPoolExecutor(int maxPoolSize, ThreadFactory threadFactory)
  • Method Details

    • shutdown

      public void shutdown()
      Specified by:
      shutdown in interface ExecutorService
      Overrides:
      shutdown in class ScheduledThreadPoolExecutor
    • shutdownNow

      public List<Runnable> shutdownNow()
      Specified by:
      shutdownNow in interface ExecutorService
      Overrides:
      shutdownNow in class ScheduledThreadPoolExecutor
    • contextDestroyed

      public void contextDestroyed(jakarta.servlet.ServletContextEvent sce)
      Specified by:
      contextDestroyed in interface jakarta.servlet.ServletContextListener
    • scheduleAdvanced

      public ScheduledFuture<?> scheduleAdvanced(Runnable command, ScheduleConfig<?> config)
      Description copied from interface: AdvancedScheduledExecutorService
      Submits an action with advanced config that becomes enabled first after the given initial delay, and subsequently with the given period or with given time after previous execution. Repeats count may be limited if provided such information in config.

      The sequence of task executions continues indefinitely until one of the following completions occur:

      • Repeat count are reached
      • Condition of specified predicate for cancellation was met
      • The task is explicitly cancelled via the returned future.
      • The executor terminates, also resulting in task cancellation.
      • An execution of the task throws an exception. In this case calling get on the returned future will throw ExecutionException, holding the exception as its cause.
      Subsequent executions are suppressed. Subsequent calls to isDone() on the returned future will return true.

      If any execution of this task takes longer than its period, then subsequent executions may start late, but will not concurrently execute.

      If task is not executed due to provided in config predicate, then repeat count does not go up. Repeats are only counted for execution that took place. So if task is specified to repeat 5 time, it will be run 5 times. For example: if task is scheduled to repeat each 10 second 5 times, and will execute 3 times, then execution predicate will prevent it from execution for 1h. The remaining 2 times will be executed after this 1h.

      Specified by:
      scheduleAdvanced in interface AdvancedScheduledExecutorService
      Parameters:
      command - the task to execute
      config - the config of task
      Returns:
      a ScheduledFuture representing pending completion of the series of repeated tasks. The future's get() method will never return normally, and will throw an exception upon task cancellation or abnormal termination of a task execution.
    • scheduleAdvanced

      public <T> ScheduledFuture<T> scheduleAdvanced(Callable<T> command, ScheduleConfig<T> config)
      Description copied from interface: AdvancedScheduledExecutorService
      Submits an action with advanced config that becomes enabled first after the given initial delay, and subsequently with the given period or with given time after previous execution. Repeats count may be limited if provided such information in config.

      The sequence of task executions continues indefinitely until one of the following completions occur:

      • Repeat count are reached
      • Condition of specified predicate for cancellation was met
      • The task is explicitly cancelled via the returned future.
      • The executor terminates, also resulting in task cancellation.
      • An execution of the task throws an exception. In this case calling get on the returned future will throw ExecutionException, holding the exception as its cause.
      Subsequent executions are suppressed. Subsequent calls to isDone() on the returned future will return true.

      If any execution of this task takes longer than its period, then subsequent executions may start late, but will not concurrently execute.

      If task is not executed due to provided in config predicate, then repeat count does not go up. Repeats are only counted for execution that took place. So if task is specified to repeat 5 time, it will be run 5 times. For example: if task is scheduled to repeat each 10 second 5 times, and will execute 3 times, then execution predicate will prevent it from execution for 1h. The remaining 2 times will be executed after this 1h.

      Specified by:
      scheduleAdvanced in interface AdvancedScheduledExecutorService
      Parameters:
      command - the task to execute
      config - the config of task
      Returns:
      a ScheduledFuture representing pending completion of the series of repeated tasks. The future's get() method will never return normally, and will throw an exception upon task cancellation or abnormal termination of a task execution.
    • reject

      final void reject(Runnable command)
    • triggerTime

      long triggerTime(long delay)
    • canRunInCurrentRunState

      boolean canRunInCurrentRunState(RunnableScheduledFuture<?> task)
    • reExecutePeriodic

      void reExecutePeriodic(RunnableScheduledFuture<?> task)