|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.springframework.scheduling.timer.ScheduledTimerTask
public class ScheduledTimerTask
JavaBean that describes a scheduled TimerTask, consisting of the TimerTask itself (or a Runnable to create a TimerTask for) and a delay plus period. Period needs to be specified; there is no point in a default for it.
The JDK Timer does not offer more sophisticated scheduling options such as cron expressions. Consider using Quartz for such advanced needs.
Note that Timer uses a TimerTask instance that is shared between repeated executions, in contrast to Quartz which instantiates a new Job for each execution.
TimerTask
,
Timer.schedule(TimerTask, long, long)
,
Timer.scheduleAtFixedRate(TimerTask, long, long)
Constructor Summary | |
---|---|
ScheduledTimerTask()
Create a new ScheduledTimerTask, to be populated via bean properties. |
|
ScheduledTimerTask(Runnable timerTask)
Create a new ScheduledTimerTask, with default one-time execution without delay. |
|
ScheduledTimerTask(Runnable timerTask,
long delay)
Create a new ScheduledTimerTask, with default one-time execution with the given delay. |
|
ScheduledTimerTask(Runnable timerTask,
long delay,
long period,
boolean fixedRate)
Create a new ScheduledTimerTask. |
|
ScheduledTimerTask(TimerTask timerTask)
Create a new ScheduledTimerTask, with default one-time execution without delay. |
|
ScheduledTimerTask(TimerTask timerTask,
long delay)
Create a new ScheduledTimerTask, with default one-time execution with the given delay. |
|
ScheduledTimerTask(TimerTask timerTask,
long delay,
long period,
boolean fixedRate)
Create a new ScheduledTimerTask. |
Method Summary | |
---|---|
long |
getDelay()
Return the delay before starting the job for the first time. |
long |
getPeriod()
Return the period between repeated task executions. |
TimerTask |
getTimerTask()
Return the TimerTask to schedule. |
boolean |
isFixedRate()
Return whether to schedule as fixed-rate execution. |
void |
setDelay(long delay)
Set the delay before starting the task for the first time, in milliseconds. |
void |
setFixedRate(boolean fixedRate)
Set whether to schedule as fixed-rate execution, rather than fixed-delay execution. |
void |
setPeriod(long period)
Set the period between repeated task executions, in milliseconds. |
void |
setRunnable(Runnable timerTask)
Set the Runnable to schedule as TimerTask. |
void |
setTimerTask(TimerTask timerTask)
Set the TimerTask to schedule. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public ScheduledTimerTask()
public ScheduledTimerTask(TimerTask timerTask)
timerTask
- the TimerTask to schedulepublic ScheduledTimerTask(TimerTask timerTask, long delay)
timerTask
- the TimerTask to scheduledelay
- the delay before starting the task for the first time (ms)public ScheduledTimerTask(TimerTask timerTask, long delay, long period, boolean fixedRate)
timerTask
- the TimerTask to scheduledelay
- 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 executionpublic ScheduledTimerTask(Runnable timerTask)
timerTask
- the Runnable to schedule as TimerTaskpublic ScheduledTimerTask(Runnable timerTask, long delay)
timerTask
- the Runnable to schedule as TimerTaskdelay
- the delay before starting the task for the first time (ms)public ScheduledTimerTask(Runnable timerTask, long delay, long period, boolean fixedRate)
timerTask
- the Runnable to schedule as TimerTaskdelay
- 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 executionMethod Detail |
---|
public void setRunnable(Runnable timerTask)
DelegatingTimerTask
public void setTimerTask(TimerTask timerTask)
public TimerTask getTimerTask()
public void setDelay(long delay)
public long getDelay()
public void setPeriod(long period)
Note that the semantics of the period vary between fixed-rate and fixed-delay execution.
setFixedRate(boolean)
public long getPeriod()
public void setFixedRate(boolean fixedRate)
See Timer javadoc for details on those execution modes.
public boolean isFixedRate()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |