freemarker.template.cache
Class UpdateTimer
java.lang.Object
|
+--freemarker.template.cache.UpdateTimer
- All Implemented Interfaces:
- java.lang.Runnable
- public final class UpdateTimer
- extends java.lang.Object
- implements java.lang.Runnable
A timer for objects that implement Updateable.
Creates a new thread, in which it periodically calls the
Updateable's update() method.
Uses techniques from the document "Why Are Thread.stop
,
Thread.suspend
, Thread.resume
and
Runtime.runFinalizersOnExit
Deprecated?", from the
Java API documentation.
- Version:
- $Id: UpdateTimer.java,v 1.9 2003/11/08 00:56:15 run2000 Exp $
Constructor Summary |
UpdateTimer(Updateable target,
long delay)
Constructs the timer with the update target and update interval. |
Method Summary |
void |
run()
Waits for the given period, then calls update() , if
required. |
void |
startTiming(int niceness)
Begins periodic automatic updates of the target. |
void |
stopTiming()
Stops (immediately) automatically updating the target. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
UpdateTimer
public UpdateTimer(Updateable target,
long delay)
- Constructs the timer with the update target and update interval.
- Parameters:
target
- the object to be updated.delay
- the number of milliseconds between updates.
startTiming
public void startTiming(int niceness)
- Begins periodic automatic updates of the target.
Since it can't be determined if an existing thread is
Runnable or not, create and start a new thread
- Parameters:
niceness
- How much to decrease the priority of the timer thread
by. The value is applied against the default priority of the new
thread. The value may be negative, to indicate that the thread should
have a greater priority than the default.
stopTiming
public void stopTiming()
- Stops (immediately) automatically updating the target.
run
public void run()
- Waits for the given period, then calls
update()
, if
required. If someone decides to kill this thread, exit immediately.
- Specified by:
run
in interface java.lang.Runnable