ch.aplu.util
Class HiResAlarmTimer

java.lang.Object
  |
  +--ch.aplu.util.BaseAlarmTimer
        |
        +--ch.aplu.util.HiResAlarmTimer

public class HiResAlarmTimer
extends BaseAlarmTimer

Class to define a alarm timer with high resolution (based on J3DTimer) (Resolution normally better than 1 microseconds.) The timer's precision is not garanteed because of multitasking/multithreading of operating system and Java. The timer starts at the given time interval, runs backwards 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
HiResAlarmTimer(long alarmTime)
          Construct a StopWatch object with better than 1 microsecond resolution on most systems and set its preset value to the given time interval in microseconds (us).
HiResAlarmTimer(long alarmTime, boolean autostart)
          Same as HiResAlarmTimer(alarmTime), but the timer starts immediately if autostart is true.
HiResAlarmTimer(long alarmTime, boolean autostart, boolean yield)
          Same as HiResAlarmTimer(alarmTime, autostart), but most methods calls Thread.yield() automatically, if yield is true.
 
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

HiResAlarmTimer

public HiResAlarmTimer(long alarmTime)
Construct a StopWatch object with better than 1 microsecond resolution on most systems and set its preset value to the given time interval in microseconds (us). The timer must be started by calling start(). It runs backwards and stops when the time is zero.


HiResAlarmTimer

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


HiResAlarmTimer

public HiResAlarmTimer(long alarmTime,
                       boolean autostart,
                       boolean yield)
Same as HiResAlarmTimer(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 ( watch.isRunning() ) {}.