Class ManagedScheduler

java.lang.Object
dev.ua.theroer.magicutils.platform.ManagedExecutor
dev.ua.theroer.magicutils.platform.ManagedScheduler
All Implemented Interfaces:
AutoCloseable

public final class ManagedScheduler extends ManagedExecutor
A thin AutoCloseable wrapper around a ScheduledExecutorService.

Extends ManagedExecutor with scheduling capabilities. Can be registered with MagicRuntime.manage() for automatic shutdown when the runtime closes.

  • Method Details

    • executor

      public ScheduledExecutorService executor()
      Returns the underlying scheduled executor for direct use.
      Overrides:
      executor in class ManagedExecutor
      Returns:
      backing scheduled executor
    • scheduleAtFixedRate

      public ScheduledFuture<?> scheduleAtFixedRate(Runnable task, long delay, long period, TimeUnit unit)
      Schedules a task at a fixed rate.
      Parameters:
      task - task to run
      delay - initial delay
      period - period between runs
      unit - time unit
      Returns:
      scheduled future handle
    • scheduleWithFixedDelay

      public ScheduledFuture<?> scheduleWithFixedDelay(Runnable task, long initialDelay, long delay, TimeUnit unit)
      Schedules a task with a fixed delay between completion and next start.
      Parameters:
      task - task to run
      initialDelay - initial delay
      delay - delay between runs
      unit - time unit
      Returns:
      scheduled future handle
    • schedule

      public ScheduledFuture<?> schedule(Runnable task, long delay, TimeUnit unit)
      Schedules a one-shot task.
      Parameters:
      task - task to run
      delay - delay before execution
      unit - time unit
      Returns:
      scheduled future handle