| |
|
| java.lang.Object java.lang.Thread net.sourceforge.jtds.util.TimerThread
TimerThread | public class TimerThread extends Thread (Code) | | Simple timer class used to implement login and query timeouts.
This thread runs as a Daemon thread to ensure that the java VM will exit
correctly when normal execution is complete.
It provides both a singleton implementation and a default constructor for
the case when more than one timer thread is desired.
author: Alin Sinpalean author: Mike Hutchinson version: $Id: TimerThread.java,v 1.5 2005/04/28 14:29:31 alin_sinpalean Exp $ |
Inner Class :public interface TimerListener | |
Constructor Summary | |
public | TimerThread() Construct a new TimerThread instance. |
Method Summary | |
public boolean | cancelTimer(Object handle) Remove a redundant timer before it expires. | public static synchronized TimerThread | getInstance() Singleton getter. | public boolean | hasExpired(Object handle) Check whether a timer has expired. | public void | run() Execute the TimerThread main loop. | public Object | setTimer(int timeout, TimerListener l) Add a timer request to the queue. |
TimerThread | public TimerThread()(Code) | | Construct a new TimerThread instance.
|
cancelTimer | public boolean cancelTimer(Object handle)(Code) | | Remove a redundant timer before it expires.
Parameters: handle - handle to the request to be removed from the queue (aTimerRequest instance) true if timer had not expired |
getInstance | public static synchronized TimerThread getInstance()(Code) | | Singleton getter.
|
hasExpired | public boolean hasExpired(Object handle)(Code) | | Check whether a timer has expired.
Parameters: handle - handle to the request to be checked for expiry (aTimerRequest instance) true if timer has expired |
run | public void run()(Code) | | Execute the TimerThread main loop.
|
setTimer | public Object setTimer(int timeout, TimerListener l)(Code) | | Add a timer request to the queue.
The queue is ordered by time so that the head of the list is always the
first timer to expire.
Parameters: timeout - the interval in milliseconds after which the timer willexpire Parameters: l - TimerListener to be notified on timeout a handle to the timer request, that can later be used withcancelTimer |
|
|
|