public class HisTimer
extends Thread
Since a new thread is created for every timer instance, the class is not recommended for frequent use, and it is not used in the ordinary logic flow of the Java DMH client or server implementations.
A similar effect can be obtained using:
new Thread(new Runnable() { public void run() { Thread.sleep(millisecs); doSomething(); } }).start();
Here is example use of a timer:
class mine implements HisTimeoutItf { public void hisTimeout(Object timer) { ... } timer a1 = new timer(20000, myobj); // use a1.stop() to cancel
Constructor and Description |
---|
HisTimer(long millisecs,
HisTimeoutItf target)
Construct a timer and start it running.
|
Modifier and Type | Method and Description |
---|---|
void |
run()
Run() is called internally by Thread.start().
|
String |
toString()
The string representation is classname@hashcode.
|
activeCount, checkAccess, 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, yield
public HisTimer(long millisecs, HisTimeoutItf target)
millisecs
- the timeout interval in milliseconds.target
- the object to be notified by calling timeout().