public static interface TimedScheduler.TimedWorker extends Scheduler.Worker
Modifier and Type | Method and Description |
---|---|
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.
|
schedule, shutdown
Cancellation schedule(java.lang.Runnable task, long delay, java.util.concurrent.TimeUnit unit)
This method is safe to be called from multiple threads and tasks are executed in some total order. Two tasks scheduled at a same time with the same delay will be ordered in FIFO order if the schedule() was called from the same thread or in arbitrary order if the schedule() was called from different threads.
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.
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 time