public class TimerThread
extends java.lang.Thread
| Modifier and Type | Class and Description | 
|---|---|
| static interface  | TimerThread.TimerListenerInterface to be implemented by classes that request timer services. | 
| private static class  | TimerThread.TimerRequestInternal class associating a login or query timeout value with a target
  TimerListener. | 
| Modifier and Type | Field and Description | 
|---|---|
| private static TimerThread | instanceSingleton instance. | 
| private long | nextTimeoutTime when the first request time out should occur. | 
| private java.util.LinkedList | timerListList of  TimerRequests to execute, ordered by time. | 
| Constructor and Description | 
|---|
| TimerThread()Construct a new  TimerThreadinstance. | 
| Modifier and Type | Method and Description | 
|---|---|
| boolean | cancelTimer(java.lang.Object handle)Remove a redundant timer before it expires. | 
| static TimerThread | getInstance()Singleton getter. | 
| boolean | hasExpired(java.lang.Object handle)Check whether a timer has expired. | 
| void | run()Execute the  TimerThreadmain loop. | 
| java.lang.Object | setTimer(int timeout,
        TimerThread.TimerListener l)Add a timer request to the queue. | 
| static void | stopTimer()Completely stops the timer and its underlying Java thread, discarding all
 pending timeouts. | 
| private void | updateNextTimeout()Internal method that updates the value of  nextTimeout. | 
activeCount, checkAccess, clone, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yieldprivate static TimerThread instance
private final java.util.LinkedList timerList
TimerRequests to execute, ordered by time.private long nextTimeout
public static TimerThread getInstance()
public void run()
TimerThread main loop.run in interface java.lang.Runnablerun in class java.lang.Threadpublic java.lang.Object setTimer(int timeout,
                        TimerThread.TimerListener l)
timeout - the interval in milliseconds after which the timer will
                expirel - TimerListener to be notified on timeoutcancelTimerpublic boolean cancelTimer(java.lang.Object handle)
handle - handle to the request to be removed from the queue (a
        TimerRequest instance)true if timer had not expiredpublic static void stopTimer()
getInstance()
 will restart the timer.public boolean hasExpired(java.lang.Object handle)
handle - handle to the request to be checked for expiry (a
        TimerRequest instance)true if timer has expiredprivate void updateNextTimeout()
nextTimeout.Generated on June 8 2013