Interface Scheduler


public interface Scheduler
Scheduler for running tasks asynchronously or with delays.
  • Method Details

    • buildTask

      @Nonnull TaskBuilder buildTask(@Nonnull Object plugin, @Nonnull Runnable task)
      Create a new task builder.
      Parameters:
      plugin - the plugin scheduling the task
      task - the task to run
      Returns:
      a task builder
    • runAsync

      @Nonnull ScheduledTask runAsync(@Nonnull Object plugin, @Nonnull Runnable task)
      Run a task immediately on the async thread pool.
      Parameters:
      plugin - the plugin scheduling the task
      task - the task to run
      Returns:
      the scheduled task
    • runLater

      @Nonnull ScheduledTask runLater(@Nonnull Object plugin, @Nonnull Runnable task, long delay, @Nonnull TimeUnit unit)
      Run a task after a delay.
      Parameters:
      plugin - the plugin scheduling the task
      task - the task to run
      delay - the delay before running
      unit - the time unit of the delay
      Returns:
      the scheduled task
    • runRepeating

      @Nonnull ScheduledTask runRepeating(@Nonnull Object plugin, @Nonnull Runnable task, long initialDelay, long period, @Nonnull TimeUnit unit)
      Run a task repeatedly at a fixed rate.
      Parameters:
      plugin - the plugin scheduling the task
      task - the task to run
      initialDelay - the delay before the first run
      period - the period between runs
      unit - the time unit
      Returns:
      the scheduled task
    • cancelAll

      void cancelAll(@Nonnull Object plugin)
      Cancel all tasks scheduled by a plugin.
      Parameters:
      plugin - the plugin whose tasks should be cancelled