Interface Scheduler
public interface Scheduler
Scheduler for running tasks asynchronously or with delays.
-
Method Summary
Modifier and TypeMethodDescriptionCreate a new task builder.voidCancel all tasks scheduled by a plugin.Run a task immediately on the async thread pool.Run a task after a delay.runRepeating(Object plugin, Runnable task, long initialDelay, long period, TimeUnit unit) Run a task repeatedly at a fixed rate.
-
Method Details
-
buildTask
Create a new task builder.- Parameters:
plugin- the plugin scheduling the tasktask- the task to run- Returns:
- a task builder
-
runAsync
Run a task immediately on the async thread pool.- Parameters:
plugin- the plugin scheduling the tasktask- 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 tasktask- the task to rundelay- the delay before runningunit- 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 tasktask- the task to runinitialDelay- the delay before the first runperiod- the period between runsunit- the time unit- Returns:
- the scheduled task
-
cancelAll
Cancel all tasks scheduled by a plugin.- Parameters:
plugin- the plugin whose tasks should be cancelled
-