org.objectweb.jotm
Class TimerManager
public class TimerManager
A timer manager manages 2 lists of timers with 2 threads
One thread is a clock which decrements timers every second
and passes them when expired in a list of expired timers.
The other thread looks in the list of expired timers to process
them.
TimerEvent | addTimer(TimerEventListener tel, long timeout, Object arg, boolean permanent) - add a new timer in the list
|
void | batch() - process all expired timers
|
void | clock() - cney speed up the clock x1000 when shutting down
update all timers in the list
each timer expired is put in a special list of expired timers
they will be processed then by the Batch Thread.
|
static TimerManager | getInstance() - Get an instance of the TimerManager
|
void | removeTimer(TimerEvent te)
|
static void | stop()
|
static void | stop(boolean force) - stop the service
|
addTimer
public TimerEvent addTimer(TimerEventListener tel,
long timeout,
Object arg,
boolean permanent)
add a new timer in the list
tel
- Object that will be notified when the timer expire.timeout
- nb of seconds before the timer expires.arg
- info passed with the timerpermanent
- true if the timer is permanent.
batch
public void batch()
process all expired timers
clock
public void clock()
cney speed up the clock x1000 when shutting down
update all timers in the list
each timer expired is put in a special list of expired timers
they will be processed then by the Batch Thread.
getInstance
public static TimerManager getInstance()
Get an instance of the TimerManager
removeTimer
public void removeTimer(TimerEvent te)
remove a timer from the list. this is not very efficient.
A better way to do this is TimerEvent.unset()
stop
public static void stop()
stop
public static void stop(boolean force)
stop the service
force
- tell the manager NOT to wait for the timers to be completed