open class ScheduledExecutorTask
JavaBean that describes a scheduled executor task, consisting of the Runnable and a delay plus period. The period needs to be specified; there is no point in a default for it.
The java.util.concurrent.ScheduledExecutorService does not offer more sophisticated scheduling options such as cron expressions. Consider using ThreadPoolTaskScheduler for such needs.
Note that the java.util.concurrent.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.
Author
Juergen Hoeller
Since
2.0
See Also
java.util.concurrent.ScheduledExecutorService#scheduleWithFixedDelay(java.lang.Runnable, long, long, java.util.concurrent.TimeUnit)java.util.concurrent.ScheduledExecutorService#scheduleAtFixedRate(java.lang.Runnable, long, long, java.util.concurrent.TimeUnit)
ScheduledExecutorTask()
Create a new ScheduledExecutorTask, to be populated via bean properties. ScheduledExecutorTask(executorTask: Runnable)
Create a new ScheduledExecutorTask, with default one-time execution without delay. ScheduledExecutorTask(executorTask: Runnable, delay: Long)
Create a new ScheduledExecutorTask, with default one-time execution with the given delay. ScheduledExecutorTask(executorTask: Runnable, delay: Long, period: Long, fixedRate: Boolean)
Create a new ScheduledExecutorTask. |
open fun getDelay(): Long
Return the delay before starting the job for the first time. |
|
open fun getPeriod(): Long
Return the period between repeated task executions. |
|
open fun getRunnable(): Runnable
Return the Runnable to schedule as executor task. |
|
open fun getTimeUnit(): TimeUnit
Return the time unit for the delay and period values. |
|
open fun isFixedRate(): Boolean
Return whether to schedule as fixed-rate execution. |
|
open fun isOneTimeTask(): Boolean
Is this task only ever going to execute once? |
|
open fun setDelay(delay: Long): Unit
Set the delay before starting the task for the first time, in milliseconds. Default is 0, immediately starting the task after successful scheduling. |
|
open fun setFixedRate(fixedRate: Boolean): Unit
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. |
|
open fun setPeriod(period: Long): Unit
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 inbetween 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 |
|
open fun setRunnable(executorTask: Runnable): Unit
Set the Runnable to schedule as executor task. |
|
open fun setTimeUnit(timeUnit: TimeUnit): Unit
Specify the time unit for the delay and period values. Default is milliseconds ( |