public interface Scheduler
Manages the scheduling and execution of tasks.
-
Method Summary
<T> Future<T>
Calls a method on the main thread and returns a Future object.
Schedule a task to be executed asynchronously.
Schedules a task to be executed asynchronously after the specified delay
is up.
Schedule a task to be executed synchronously.
Schedules a task to be executed synchronously after the specified delay
is up.
Schedules a task to be executed asynchronously after the specified delay
is up.
Schedules a task to be executed asynchronously after the specified delay
is up.
-
Method Details
-
runSync
Task runSync(Runnable task)
Schedule a task to be executed synchronously. The task will commence
running as soon as this method returns.
- Parameters:
-
task - the task to run
- Returns:
- the scheduled task
-
runSync
Task runSync(Runnable task,
long delay)
Schedules a task to be executed synchronously after the specified delay
is up.
- Parameters:
-
task - the task to run
-
delay - the delay before this task will be executed (tick units)
- Returns:
- the scheduled task
-
runAsync
Task runAsync(Runnable task)
Schedule a task to be executed asynchronously. The task will commence
running as soon as this method returns.
- Parameters:
-
task - the task to run
- Returns:
- the scheduled task
-
runAsync
Task runAsync(Runnable task,
long delay)
Schedules a task to be executed asynchronously after the specified delay
is up.
- Parameters:
-
task - the task to run
-
delay - the delay before this task will be executed (tick units)
- Returns:
- the scheduled task
-
scheduleSync
Task scheduleSync(Runnable task,
long delay,
long period)
Schedules a task to be executed asynchronously after the specified delay
is up. The scheduled task will continue running at the specified
interval. The interval will not begin to count down until the last task
invocation is complete.
- Parameters:
-
task - the task to run
-
delay - the delay before this task will be executed
-
period - the interval before subsequent executions of this task
- Returns:
- the scheduled task
-
scheduleAsync
Task scheduleAsync(Runnable task,
long delay,
long period)
Schedules a task to be executed asynchronously after the specified delay
is up. The scheduled task will continue running at the specified
interval. The interval will not begin to count down until the last task
invocation is complete.
- Parameters:
-
task - the task to run
-
delay - the delay before this task will be executed
-
period - the interval before subsequent executions of this task
- Returns:
- the scheduled task
-
callSyncMethod
<T> Future<T> callSyncMethod(Callable<T> task)
Calls a method on the main thread and returns a Future object. This
task will be executed by the main server thread.
- Note: The Future.get() methods must NOT be called from the main
thread.
- Note2: There is at least an average of 10ms latency until the
isDone() method returns true.
- Type Parameters:
-
T - The callable's return type
- Parameters:
-
task - Task to be executed
- Returns:
- Future Future object related to the task