ch.aplu.util
Class LoResAlarmTimer

java.lang.Object
  extended by ch.aplu.util.BaseAlarmTimer
      extended by ch.aplu.util.LoResAlarmTimer

public class LoResAlarmTimer
extends BaseAlarmTimer

Alarm timer with low resolution (Resolution normally less than 10 milliseconds.) The timer starts at the given preset time, runs backward and stops when it reaches zero.

(When using timer events by registering a TimerListener, the AlarmTimer restarts automatically.)

(All timer manipulation methods call yield() of the current thread unless disabled by special constructor.)


Constructor Summary
LoResAlarmTimer(long alarmTime)
          Construct a AlarmTimer instance and set its preset time in microseconds (us).
LoResAlarmTimer(long alarmTime, boolean autostart)
          Same as LoResAlarmTimer(alarmTime), but the timer starts immediately if autostart is true.
LoResAlarmTimer(long alarmTime, boolean autostart, boolean yield)
          Same as LoResAlarmTimer(alarmTime, autostart), but most methods calls Thread.yield() automatically, if yield is true.
 
Method Summary
 
Methods inherited from class ch.aplu.util.BaseAlarmTimer
addTimerListener, getTime, isRunning, resume, start, start, stop, stopEvents
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LoResAlarmTimer

public LoResAlarmTimer(long alarmTime)
Construct a AlarmTimer instance and set its preset time in microseconds (us). The timer must be started by calling start(). It runs backward and stops when it reaches zero.


LoResAlarmTimer

public LoResAlarmTimer(long alarmTime,
                       boolean autostart)
Same as LoResAlarmTimer(alarmTime), but the timer starts immediately if autostart is true.


LoResAlarmTimer

public LoResAlarmTimer(long alarmTime,
                       boolean autostart,
                       boolean yield)
Same as LoResAlarmTimer(alarmTime, autostart), but most methods calls Thread.yield() automatically, if yield is true. This may give a much better time response when using loops with an empty body like

while ( timer.isRunning() ) {}.