Class ScheduledExecutorTask
Runnable and a delay plus period. The period needs to be specified;
 there is no point in a default for it.
 The ScheduledExecutorService does not offer
 more sophisticated scheduling options such as cron expressions.
 Consider using ThreadPoolTaskScheduler for such needs.
 
Note that the ScheduledExecutorService mechanism
 uses a Runnable instance that is shared between repeated executions,
 in contrast to Quartz which creates a new Job instance for each execution.
- 
Constructor SummaryConstructorsConstructorDescriptionCreate a new ScheduledExecutorTask, to be populated via bean properties.ScheduledExecutorTask(Runnable executorTask) Create a new ScheduledExecutorTask, with default one-time execution without delay.ScheduledExecutorTask(Runnable executorTask, long delay) Create a new ScheduledExecutorTask, with default one-time execution with the given delay.ScheduledExecutorTask(Runnable executorTask, long delay, long period, boolean fixedRate) Create a new ScheduledExecutorTask.
- 
Method SummaryModifier and TypeMethodDescriptionlonggetDelay()Return the delay before starting the job for the first time.longReturn the period between repeated task executions.Return the Runnable to schedule as executor task.Return the time unit for the delay and period values.booleanReturn whether to schedule as fixed-rate execution.booleanIs this task only ever going to execute once?voidsetDelay(long delay) Set the delay before starting the task for the first time, in milliseconds.voidsetFixedRate(boolean fixedRate) Set whether to schedule as fixed-rate execution, rather than fixed-delay execution.voidsetPeriod(long period) Set the period between repeated task executions, in milliseconds.voidsetRunnable(Runnable executorTask) Set the Runnable to schedule as executor task.voidsetTimeUnit(TimeUnit timeUnit) Specify the time unit for the delay and period values.
- 
Constructor Details- 
ScheduledExecutorTaskpublic ScheduledExecutorTask()Create a new ScheduledExecutorTask, to be populated via bean properties.
- 
ScheduledExecutorTaskCreate a new ScheduledExecutorTask, with default one-time execution without delay.- Parameters:
- executorTask- the Runnable to schedule
 
- 
ScheduledExecutorTaskCreate a new ScheduledExecutorTask, with default one-time execution with the given delay.- Parameters:
- executorTask- the Runnable to schedule
- delay- the delay before starting the task for the first time (ms)
 
- 
ScheduledExecutorTaskCreate a new ScheduledExecutorTask.- Parameters:
- executorTask- the Runnable to schedule
- delay- the delay before starting the task for the first time (ms)
- period- the period between repeated task executions (ms)
- fixedRate- whether to schedule as fixed-rate execution
 
 
- 
- 
Method Details- 
setRunnableSet the Runnable to schedule as executor task.
- 
getRunnableReturn the Runnable to schedule as executor task.
- 
setDelaypublic void setDelay(long delay) Set the delay before starting the task for the first time, in milliseconds. Default is 0, immediately starting the task after successful scheduling.
- 
getDelaypublic long getDelay()Return the delay before starting the job for the first time.
- 
setPeriodpublic void setPeriod(long period) Set the period between repeated task executions, in milliseconds.Default is -1, leading to one-time execution. In case of a positive value, the task will be executed repeatedly, with the given interval in-between executions. Note that the semantics of the period value vary between fixed-rate and fixed-delay execution. Note: A period of 0 (for example as fixed delay) is not supported, simply because java.util.concurrent.ScheduledExecutorServiceitself does not support it. Hence a value of 0 will be treated as one-time execution; however, that value should never be specified explicitly in the first place!
- 
getPeriodpublic long getPeriod()Return the period between repeated task executions.
- 
isOneTimeTaskpublic boolean isOneTimeTask()Is this task only ever going to execute once?- Returns:
- trueif this task is only ever going to execute once
- See Also:
 
- 
setTimeUnitSpecify the time unit for the delay and period values. Default is milliseconds (TimeUnit.MILLISECONDS).- See Also:
 
- 
getTimeUnitReturn the time unit for the delay and period values.
- 
setFixedRatepublic void setFixedRate(boolean fixedRate) Set whether to schedule as fixed-rate execution, rather than fixed-delay execution. Default is "false", that is, fixed delay.See ScheduledExecutorService javadoc for details on those execution modes. 
- 
isFixedRatepublic boolean isFixedRate()Return whether to schedule as fixed-rate execution.
 
-