public class IntervalTask extends Task
Task
implementation defining a Runnable
to be executed at a given
millisecond interval which may be treated as fixed-rate or fixed-delay depending on
context.ScheduledTaskRegistrar.addFixedRateTask(IntervalTask)
,
ScheduledTaskRegistrar.addFixedDelayTask(IntervalTask)
Constructor and Description |
---|
IntervalTask(java.lang.Runnable runnable,
long interval)
Create a new
IntervalTask with no initial delay. |
IntervalTask(java.lang.Runnable runnable,
long interval,
long initialDelay)
Create a new
IntervalTask . |
Modifier and Type | Method and Description |
---|---|
long |
getInitialDelay()
Return the initial delay before first execution of the task.
|
long |
getInterval()
Return how often in milliseconds the task should be executed.
|
getRunnable, toString
public IntervalTask(java.lang.Runnable runnable, long interval, long initialDelay)
IntervalTask
.runnable
- the underlying task to executeinterval
- how often in milliseconds the task should be executedinitialDelay
- the initial delay before first execution of the taskpublic IntervalTask(java.lang.Runnable runnable, long interval)
IntervalTask
with no initial delay.runnable
- the underlying task to executeinterval
- how often in milliseconds the task should be executed