com.rubecula.darwin.core
Class GenerationTimerTask
java.lang.Object
java.util.TimerTask
com.rubecula.darwin.core.GenerationTimerTask
- All Implemented Interfaces:
- Runnable
public class GenerationTimerTask
- extends TimerTask
Timer Task which, when in "running" state, will invoke the next generation of
a Generatable object (provided by the constructor).
Whether or not, running is true, a callback to contructor-provided implementer
of GenerationListener (if not null) will be invoked.
- Author:
- Robin
|
Field Summary |
protected static org.apache.commons.logging.Log |
log
The logger for this class. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
log
protected static final org.apache.commons.logging.Log log
- The logger for this class.
GenerationTimerTask
public GenerationTimerTask(Generatable generatable,
GenerationListener listener,
int rate,
boolean start)
- Parameters:
generatable - a Generatable object whose nextGeneration() method will be invoked
whenever the timer task wakes up (provided that the task is in "running" state).listener - an implementer of GenerationListener whose callback will
be invoked every time the timer wakes up (after the nextGeneration is invoked),
regardless of the running state. listener may be null.rate - the number of millisecs for the initial delay and subsequent delays.start - the initial running state (if true, then the timer starts running immediately).
getGeneratable
public Generatable getGeneratable()
- Returns:
- the generatable
resetRate
public GenerationTimerTask resetRate(int millisecs)
run
public void run()
- Specified by:
run in interface Runnable- Specified by:
run in class TimerTask
setRunning
public void setRunning(boolean running)
- Parameters:
running - the running to set
isRunning
protected boolean isRunning()
- Returns:
- the running