|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--nl.justobjects.toolkit.sys.Timer
Interval timer thread with callback to client.
Purpose
It calls the tick method in the TimerCallback interface after
a fixed number of milliseconds (indicated by the
interval variable). It measures the amount of time spent
in the tick method and adjusts for it.
Implementation
Examples
To start up a timer with this class, create it with
a callback and the number of milliseconds in the interval
then call the start method:
Timer timer = new Timer(this, 2000); // 2 second interval timer.start();
$Source: /var/cvs/justobjects/toolkit/src/nl/justobjects/toolkit/sys/Timer.java,v $
TimerCallback
Field Summary | |
protected TimerCallback |
callback
The callback interface containing the tick method |
protected long |
interval
The number of milliseconds in the interval |
(package private) static int |
num
|
protected java.lang.Thread |
timerThread
|
Constructor Summary | |
Timer()
|
|
Timer(long interval)
|
|
Timer(TimerCallback callback)
|
|
Timer(TimerCallback callback,
long interval)
|
Method Summary | |
TimerCallback |
getCallback()
returns the callback interface |
long |
getInterval()
returns the number of milliseconds in the interval |
void |
run()
|
void |
setCallback(TimerCallback callback)
changes the callback interface |
void |
setInterval(long newInterval)
sets the number of milliseconds in the interval |
void |
start()
|
void |
stop()
|
Methods inherited from class java.lang.Object |
|
Field Detail |
static int num
protected java.lang.Thread timerThread
protected long interval
protected TimerCallback callback
Constructor Detail |
public Timer()
public Timer(TimerCallback callback)
public Timer(long interval)
public Timer(TimerCallback callback, long interval)
Method Detail |
public long getInterval()
public void setInterval(long newInterval)
newInterval
- the new number of millisecondspublic TimerCallback getCallback()
public void setCallback(TimerCallback callback)
callback
- the new callbackpublic void start()
public void stop()
public void run()
run
in interface java.lang.Runnable
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |