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
-
Timer()
- Create a timer.
-
addTimerListener(TimerListener)
-
-
closeTimerSession(Object)
- Remove the key from the timer's open
sessions list.
-
dispose()
-
-
fireTimerExpired()
-
-
getElapsedTime(Object)
- Return the elapsed time counter for
the timer session.
-
getMark()
- Return the current marked time.
-
hasTimerSession(Object)
- Report whether a timer session has been
opened for the given key.
-
mark()
- Mark the current time.
-
openTimerSession(Object)
- Register a timer session identified by
the given key.
-
removeTimerListener(TimerListener)
-
-
resetTimer(Object)
- Reset the elapsed time counter for
the timer session
-
run()
-
-
setMark(long)
- Mark the specified time.
-
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.
-
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.
-
stopTimer()
- Stop any existing delay timer.
-
waitUntil(long)
- Wait until
the specified time from the current mark.
-
waitUntil(long, Object, boolean)
- Wait upon the specified monitor until
the specified time from the current mark,
and optionally ignoring notifies to the monitor.
-
waitUntil(Object, long)
- Wait until a given elapsed time from the
last reset of the timer session.
-
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.
Timer
public Timer()
- Create a timer. The time of creation
becomes the initial mark.
mark
public void mark()
- Mark the current time. Timing intervals
are measured from the mark.
setMark
public void setMark(long time)
- Mark the specified time. Timing intervals
are measured from the mark.
getMark
public long getMark()
- Return the current marked time.
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.
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.
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.
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.
stopTimer
public void stopTimer()
- Stop any existing delay timer.
run
public void run()
addTimerListener
public void addTimerListener(TimerListener timerListener)
removeTimerListener
public void removeTimerListener(TimerListener timerListener)
fireTimerExpired
protected void fireTimerExpired()
dispose
public void dispose()
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
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
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
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
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
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
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