Runnable and a delay plus period. The period needs to be specified;
there is no point in a default for it.
The java. does not offer
more sophisticated scheduling options such as cron expressions.
Consider using ThreadPoolTaskScheduler for such needs.
Note that the java. mechanism
uses a Runnable instance that is shared between repeated executions,
in contrast to Quartz which creates a new Job instance for each execution.
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)
| Modifier and Type | Field and Description |
|---|---|
| private long | |
| private boolean | |
| private long | |
| private Runnable | |
| private TimeUnit |
| Access | Constructor and Description |
|---|---|
| public | |
| public | ScheduledExecutorTask(Runnable
the Runnable to schedule executorTask)Create a new ScheduledExecutorTask, with default one-time execution without delay. |
| public | ScheduledExecutorTask(Runnable
the Runnable to schedule executorTask, long the delay before starting the task for the first time (ms) delay)Create a new ScheduledExecutorTask, with default one-time execution with the given delay. |
| public | ScheduledExecutorTask(Runnable
the Runnable to schedule executorTask, long the delay before starting the task for the first time (ms) delay, long the period between repeated task executions (ms) period, boolean whether to schedule as fixed-rate execution fixedRate)Create a new ScheduledExecutorTask. |
| Modifier and Type | Method and Description |
|---|---|
| public long | |
| public long | |
| public Runnable | |
| public TimeUnit | |
| public boolean | |
| public boolean | Returns: true if this task is only ever going to execute onceIs this task only ever going to execute once? |
| public void | |
| public void | setFixedRate(boolean fixedRate)
Set whether to schedule as fixed-rate execution, rather than fixed-delay execution. |
| public void | |
| public void | |
| public void |
| delay | back to summary |
|---|---|
| private long delay | |
| fixedRate | back to summary |
|---|---|
| private boolean fixedRate | |
| period | back to summary |
|---|---|
| private long period | |
| runnable | back to summary |
|---|---|
| private Runnable runnable
| |
| timeUnit | back to summary |
|---|---|
| private TimeUnit timeUnit | |
| ScheduledExecutorTask | back to summary |
|---|---|
| public ScheduledExecutorTask() Create a new ScheduledExecutorTask, to be populated via bean properties.
| |
| ScheduledExecutorTask | back to summary |
|---|---|
| public ScheduledExecutorTask(Runnable executorTask) Create a new ScheduledExecutorTask, with default one-time execution without delay.
| |
| ScheduledExecutorTask | back to summary |
|---|---|
| public ScheduledExecutorTask(Runnable executorTask, long delay) Create a new ScheduledExecutorTask, with default one-time execution with the given delay.
| |
| ScheduledExecutorTask | back to summary |
|---|---|
| public ScheduledExecutorTask(Runnable executorTask, long delay, long period, boolean fixedRate) Create a new ScheduledExecutorTask.
| |
| getDelay | back to summary |
|---|---|
| public long getDelay() Return the delay before starting the job for the first time. | |
| getPeriod | back to summary |
|---|---|
| public long getPeriod() Return the period between repeated task executions. | |
| getRunnable | back to summary |
|---|---|
| public Runnable getRunnable() Return the Runnable to schedule as executor task. | |
| getTimeUnit | back to summary |
|---|---|
| public TimeUnit getTimeUnit() Return the time unit for the delay and period values. | |
| isFixedRate | back to summary |
|---|---|
| public boolean isFixedRate() Return whether to schedule as fixed-rate execution. | |
| isOneTimeTask | back to summary |
|---|---|
| public boolean isOneTimeTask() Is this task only ever going to execute once?
| |
| setDelay | back to summary |
|---|---|
| public 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. | |
| setFixedRate | back to summary |
|---|---|
| public 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. | |
| setPeriod | back to summary |
|---|---|
| public 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 | |
| setRunnable | back to summary |
|---|---|
| public void setRunnable(Runnable executorTask) Set the Runnable to schedule as executor task. | |
| setTimeUnit | back to summary |
|---|---|
| public void setTimeUnit(TimeUnit timeUnit) Specify the time unit for the delay and period values.
Default is milliseconds ( | |