All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class com.ibm.eou.toolkit.util.Timer

java.lang.Object
   |
   +----com.ibm.eou.toolkit.util.Timer

public class Timer
extends Object
implements Runnable

Constructor Index

 o Timer()
Create a timer.

Method Index

 o addTimerListener(TimerListener)
 o closeTimerSession(Object)
Remove the key from the timer's open sessions list.
 o dispose()
 o fireTimerExpired()
 o getElapsedTime(Object)
Return the elapsed time counter for the timer session.
 o getMark()
Return the current marked time.
 o hasTimerSession(Object)
Report whether a timer session has been opened for the given key.
 o mark()
Mark the current time.
 o openTimerSession(Object)
Register a timer session identified by the given key.
 o removeTimerListener(TimerListener)
 o resetTimer(Object)
Reset the elapsed time counter for the timer session
 o run()
 o setMark(long)
Mark the specified time.
 o startTimer(long, boolean)
Start a delay timer, which will expire after the specified time from the current mark (a mark can be set by calling the mark method), or immediately if the specified time has already passed.
 o startTimer(long, boolean, boolean)
Start a delay timer, which will expire after the specified time from the current mark, or from the time of the call if startNow is true.
 o stopTimer()
Stop any existing delay timer.
 o waitUntil(long)
Wait until the specified time from the current mark.
 o waitUntil(long, Object, boolean)
Wait upon the specified monitor until the specified time from the current mark, and optionally ignoring notifies to the monitor.
 o waitUntil(Object, long)
Wait until a given elapsed time from the last reset of the timer session.
 o waitUntil(Object, long, Object)
Wait until a given elapsed time from the last reset of the timer session, or until the monitor is notified, whichever occurs sooner.

Constructors

 o Timer
 public Timer()
Create a timer. The time of creation becomes the initial mark.

Methods

 o mark
 public void mark()
Mark the current time. Timing intervals are measured from the mark.

 o setMark
 public void setMark(long time)
Mark the specified time. Timing intervals are measured from the mark.

 o getMark
 public long getMark()
Return the current marked time.

 o waitUntil
 public void waitUntil(long interval) throws InterruptedException
Wait until the specified time from the current mark. The wakeup time becomes the new mark, so that repeated waits maintain exactness regardless of extra processing between calls.

Throws: InterruptedException
if another thread has interrupted this thread.
 o waitUntil
 public boolean waitUntil(long interval,
                          Object monitor,
                          boolean ignoreNotify) throws InterruptedException
Wait upon the specified monitor until the specified time from the current mark, and optionally ignoring notifies to the monitor. The wakeup time becomes the new mark, so that repeated waits maintain exactness regardless of extra processing between calls.

Returns:
true if the wait completed, or false if a notify aborted the wait.
Throws: InterruptedException
if another thread has interrupted this thread.
 o startTimer
 public void startTimer(long interval,
                        boolean recurring)
Start a delay timer, which will expire after the specified time from the current mark (a mark can be set by calling the mark method), or immediately if the specified time has already passed. That time becomes the new mark, and all timer listeners are notified. If a recurring timer is requested, the successive time intervals are measured from the preceding marks, so that the repeated waits maintain exactness regardless of extra processing by the listeners. When a new delay timer is set, any existing delay timer setting is cancelled.

 o startTimer
 public void startTimer(long interval,
                        boolean recurring,
                        boolean startNow)
Start a delay timer, which will expire after the specified time from the current mark, or from the time of the call if startNow is true. That time becomes the new mark, and all timer listeners are notified. If a recurring timer is requested, the successive time intervals are measured from the preceding marks, so that the repeated waits maintain exactness regardless of extra processing by the listeners. When a new delay timer is set, any existing delay timer setting is cancelled.

 o stopTimer
 public void stopTimer()
Stop any existing delay timer.

 o run
 public void run()
 o addTimerListener
 public void addTimerListener(TimerListener timerListener)
 o removeTimerListener
 public void removeTimerListener(TimerListener timerListener)
 o fireTimerExpired
 protected void fireTimerExpired()
 o dispose
 public void dispose()
 o openTimerSession
 public static void openTimerSession(Object key)
Register a timer session identified by the given key. The timer class maintains separate timer sessions for different keys

Parameters:
key - an object to use as the key for a timer session
See Also:
closeTimerSession
 o closeTimerSession
 public static void closeTimerSession(Object key)
Remove the key from the timer's open sessions list.

Parameters:
key - an object to use as the key for a timer session
See Also:
openTimerSession
 o hasTimerSession
 public static boolean hasTimerSession(Object key)
Report whether a timer session has been opened for the given key.

Parameters:
key - an object to be searched for in the open session list
Returns:
whether a timer session has been opened for that key
 o resetTimer
 public static void resetTimer(Object key)
Reset the elapsed time counter for the timer session

Parameters:
key - an object for which a timer session has been opened
 o getElapsedTime
 public static long getElapsedTime(Object key)
Return the elapsed time counter for the timer session.

Parameters:
key - an object for which a timer session has been opened
Returns:
elapsed time since last reset in milliseconds
 o waitUntil
 public static boolean waitUntil(Object key,
                                 long ms,
                                 Object monitor) throws InterruptedException
Wait until a given elapsed time from the last reset of the timer session, or until the monitor is notified, whichever occurs sooner. Once this method starts waiting, it will not take account of any resets of the timer that take place from other threads. When the waiting ends, the timer is reset.

Parameters:
key - an object for which a timer session has been opened
ms - elapsed time to wait in milliseconds
notifier - an object upon which to wait
Returns:
whether the specified interval fully expired (false indicates the wait was terminated by a notify)
Throws: InterruptedException
if interrupted
 o waitUntil
 public static boolean waitUntil(Object key,
                                 long ms) throws InterruptedException
Wait until a given elapsed time from the last reset of the timer session. Once this method starts waiting, it will not take account of any resets of the timer that take place from other threads. When the waiting ends, the timer is reset.

Parameters:
key - an object for which a timer session has been opened
ms - elapsed time to wait in milliseconds
Throws: InterruptedException
if interrupted

All Packages  Class Hierarchy  This Package  Previous  Next  Index