|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectwicket.util.thread.Task
public final class Task
Runs a block of code periodically. The Task can be started at a given time in the future and can be a daemon. The block of code will be passed a Log object each time it is run through its ICode interface.
If the code block takes longer than the period to run, the next task invocation will occur immediately. In this case, tasks will not occur at precise multiples of the period. For example, if you run a task every 30 seconds, and the first run takes 40 seconds but the second takes 20 seconds, your task will be invoked at 0 seconds, 40 seconds and 70 seconds (40 seconds + 30 seconds), which is not an even multiple of 30 seconds.
In general, this is a simple task class designed for polling activities. If you need precise guarantees, you probably should be using a different task class.
| Constructor Summary | |
|---|---|
Task(java.lang.String name)
Constructor. |
|
| Method Summary | |
|---|---|
protected org.apache.commons.logging.Log |
getLog()
Gets the log. |
void |
run(Duration frequency,
ICode code)
Runs this task at the given frequency. |
void |
setDaemon(boolean daemon)
Set daemon or not. |
void |
setLog(org.apache.commons.logging.Log log)
Set log for user code to log to when task runs. |
void |
setStartTime(Time startTime)
Sets start time for this task. |
void |
stop()
Will stop the task as soon as it does have that opportunity |
java.lang.String |
toString()
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public Task(java.lang.String name)
name - The name of this task| Method Detail |
|---|
public final void run(Duration frequency,
ICode code)
frequency - The frequency at which to run the codecode - The code to run
java.lang.IllegalStateException - Thrown if task is already runningpublic void setDaemon(boolean daemon)
daemon - True if this task's thread should be a daemon
java.lang.IllegalStateException - Thrown if task is already runningpublic void setLog(org.apache.commons.logging.Log log)
log - The logpublic void setStartTime(Time startTime)
startTime - The time this task should start running
java.lang.IllegalStateException - Thrown if task is already runningpublic java.lang.String toString()
toString in class java.lang.ObjectObject.toString()protected org.apache.commons.logging.Log getLog()
public void stop()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||