Modifier and Type | Interface and Description |
---|---|
static interface |
TimedScheduler.TimedWorker |
Scheduler.Worker
Modifier and Type | Method and Description |
---|---|
TimedScheduler.TimedWorker |
createWorker()
Creates a worker of this Scheduler that executed task in a strict
FIFO order, guaranteed non-concurrently with each other.
|
default long |
now(java.util.concurrent.TimeUnit unit)
Returns the "current time" notion of this scheduler.
|
Cancellation |
schedule(java.lang.Runnable task,
long delay,
java.util.concurrent.TimeUnit unit)
Schedules the execution of the given task with the given delay amount.
|
Cancellation |
schedulePeriodically(java.lang.Runnable task,
long initialDelay,
long period,
java.util.concurrent.TimeUnit unit)
Schedules a periodic execution of the given task with the given initial delay and period.
|
Cancellation schedule(java.lang.Runnable task, long delay, java.util.concurrent.TimeUnit unit)
This method is safe to be called from multiple threads but there are no ordering guarantees between tasks.
task
- the task to scheduledelay
- the delay amount, non-positive values indicate non-delayed schedulingunit
- the unit of measure of the delay amountCancellation schedulePeriodically(java.lang.Runnable task, long initialDelay, long period, java.util.concurrent.TimeUnit unit)
This method is safe to be called from multiple threads but there are no ordering guarantees between tasks.
The periodic execution is at a fixed rate, that is, the first execution will be after the initial delay, the second after initialDelay + period, the third after initialDelay + 2 * period, and so on.
task
- the task to scheduleinitialDelay
- the initial delay amount, non-positive values indicate non-delayed schedulingperiod
- the period at which the task should be re-executedunit
- the unit of measure of the delay amountdefault long now(java.util.concurrent.TimeUnit unit)
unit
- the target unit of the current timeTimedScheduler.TimedWorker createWorker()
Scheduler
Once the Worker is no longer in use, one should call shutdown() on it to release any resources the particular Scheduler may have used.
Tasks scheduled with this worker run in FIFO order and strictly non-concurrently, but there are no ordering guarantees between different Workers created from the same Scheduler.
createWorker
in interface Scheduler