| java.lang.Object org.springframework.scheduling.backportconcurrent.ScheduledExecutorTask
ScheduledExecutorTask | public class ScheduledExecutorTask (Code) | | 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 JSR-166 backport
edu.emory.mathcs.backport.java.util.concurrent.ScheduledExecutorService does not offer more sophisticated scheduling options such as cron expressions.
Consider using Quartz for such advanced needs.
Note that the
edu.emory.mathcs.backport.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.
This class is analogous to the
org.springframework.scheduling.timer.ScheduledTimerTask class for the JDK
java.util.Timer facility.
author: Juergen Hoeller since: 2.0.3 See Also: edu.emory.mathcs.backport.java.util.concurrent.ScheduledExecutorService.scheduleWithFixedDelay(java.lang.Runnablelonglongedu.emory.mathcs.backport.java.util.concurrent.TimeUnit) See Also: edu.emory.mathcs.backport.java.util.concurrent.ScheduledExecutorService.scheduleAtFixedRate(java.lang.Runnablelonglongedu.emory.mathcs.backport.java.util.concurrent.TimeUnit) See Also: org.springframework.scheduling.timer.ScheduledTimerTask |
Constructor Summary | |
public | ScheduledExecutorTask() Create a new ScheduledExecutorTask,
to be populated via bean properties. | public | ScheduledExecutorTask(Runnable executorTask) Create a new ScheduledExecutorTask, with default
one-time execution without delay. | public | ScheduledExecutorTask(Runnable executorTask, long delay) Create a new ScheduledExecutorTask, with default
one-time execution with the given delay. | public | ScheduledExecutorTask(Runnable executorTask, long delay, long period, boolean fixedRate) Create a new ScheduledExecutorTask. |
Method Summary | |
public long | getDelay() Return the delay before starting the job for the first time. | public long | getPeriod() Return the period between repeated task executions. | public Runnable | getRunnable() Return the Runnable to schedule as executor task. | public TimeUnit | getTimeUnit() Return the time unit for the delay and period values. | public boolean | isFixedRate() Return whether to schedule as fixed-rate execution. | public boolean | isOneTimeTask() | public void | setDelay(long delay) Set the delay before starting the task for the first time,
in milliseconds. | public void | setFixedRate(boolean fixedRate) Set whether to schedule as fixed-rate execution, rather than
fixed-delay execution. | public void | setPeriod(long period) Set the period between repeated task executions, in milliseconds.
Default is -1, leading to one-time execution. | public void | setRunnable(Runnable executorTask) Set the Runnable to schedule as executor task. | public void | setTimeUnit(TimeUnit timeUnit) Specify the time unit for the delay and period values. |
ScheduledExecutorTask | public ScheduledExecutorTask(Runnable executorTask)(Code) | | Create a new ScheduledExecutorTask, with default
one-time execution without delay.
Parameters: executorTask - the Runnable to schedule |
ScheduledExecutorTask | public ScheduledExecutorTask(Runnable executorTask, long delay)(Code) | | Create a new ScheduledExecutorTask, with default
one-time execution with the given delay.
Parameters: executorTask - the Runnable to schedule Parameters: delay - the delay before starting the task for the first time (ms) |
ScheduledExecutorTask | public ScheduledExecutorTask(Runnable executorTask, long delay, long period, boolean fixedRate)(Code) | | Create a new ScheduledExecutorTask.
Parameters: executorTask - the Runnable to schedule Parameters: delay - the delay before starting the task for the first time (ms) Parameters: period - the period between repeated task executions (ms) Parameters: fixedRate - whether to schedule as fixed-rate execution |
getDelay | public long getDelay()(Code) | | Return the delay before starting the job for the first time.
|
getPeriod | public long getPeriod()(Code) | | Return the period between repeated task executions.
|
getRunnable | public Runnable getRunnable()(Code) | | Return the Runnable to schedule as executor task.
|
getTimeUnit | public TimeUnit getTimeUnit()(Code) | | Return the time unit for the delay and period values.
|
isFixedRate | public boolean isFixedRate()(Code) | | Return whether to schedule as fixed-rate execution.
|
setDelay | public void setDelay(long delay)(Code) | | Set the delay before starting the task for the first time,
in milliseconds. Default is 0, immediately starting the
task after successful scheduling.
|
setFixedRate | public void setFixedRate(boolean fixedRate)(Code) | | 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.
See Also: edu.emory.mathcs.backport.java.util.concurrent.ScheduledExecutorService.scheduleWithFixedDelay(java.lang.Runnablelonglongedu.emory.mathcs.backport.java.util.concurrent.TimeUnit) See Also: edu.emory.mathcs.backport.java.util.concurrent.ScheduledExecutorService.scheduleAtFixedRate(java.lang.Runnablelonglongedu.emory.mathcs.backport.java.util.concurrent.TimeUnit) |
setPeriod | public void setPeriod(long period)(Code) | | 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 edu.emory.mathcs.backport.java.util.concurrent.ScheduledExecutorService itself
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!
See Also: ScheduledExecutorTask.setFixedRate See Also: ScheduledExecutorTask.isOneTimeTask() See Also: edu.emory.mathcs.backport.java.util.concurrent.ScheduledExecutorService.scheduleWithFixedDelay(java.lang.Runnablelonglongedu.emory.mathcs.backport.java.util.concurrent.TimeUnit) |
setRunnable | public void setRunnable(Runnable executorTask)(Code) | | Set the Runnable to schedule as executor task.
|
setTimeUnit | public void setTimeUnit(TimeUnit timeUnit)(Code) | | Specify the time unit for the delay and period values.
Default is milliseconds (TimeUnit.MILLISECONDS ).
See Also: edu.emory.mathcs.backport.java.util.concurrent.TimeUnit.MILLISECONDS See Also: edu.emory.mathcs.backport.java.util.concurrent.TimeUnit.SECONDS |
|
|