|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.elkoserver.foundation.timer.Timer
public class Timer
The master control object for scheduling timed events using timeouts and
clocks. One-time events (controlled by Timeout objects) may be
scheduled by calling either of the after() methods.
Recurring events (controlled by Clock objects) may be scheduled by
calling either of the every() methods.
Event notification is guaranteed to be prompt but not immediate: the event handler will be invoked no sooner than scheduled and as soon thereafter as possible, but no guarantees are offered that somewhat more time will not have passed than was requested. In particular, while the scheduling API lets you specify times with millisecond precision, millisecond accuracy in practice should not be assumed.
| Method Summary | |
|---|---|
Timeout |
after(long millis,
TimeoutNoticer target)
Sets a timeout for the specified number of milliseconds. |
Timeout |
after(long millis,
TimeoutNoticer target,
boolean synchronous)
Sets a timeout for the specified number of milliseconds. |
Clock |
every(long resolution,
TickNoticer target)
Creates a new clock. |
Clock |
every(long resolution,
TickNoticer target,
boolean synchronous)
Creates a new clock. |
static Timer |
theTimer()
Return the single permitted Timer instance. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method Detail |
|---|
public Timeout after(long millis,
TimeoutNoticer target,
boolean synchronous)
noticeTimeout() method is called.
millis - How long to wait until timing out.target - Object to be informed when the time comes.synchronous - Flag controlling synchronous notification of the
timeout. If true, notify synchronously; if false,
post notification on the message queue. Note that great care should
be taken with synchronous notification as it introduces threading
issues; do not use synchronous notification unless you understand
these issues thoroughly (and, by the way, you don't).
TimeoutNoticer
public Timeout after(long millis,
TimeoutNoticer target)
noticeTimeout() method is called. Notification is always asynchronous:
this method is equivalent to the after(long,TimeoutNoticer,boolean) method where the
synchronous argument is set to false.
millis - How long to wait until timing out.target - Object to be informed when the time comes.
TimeoutNoticer
public Clock every(long resolution,
TickNoticer target,
boolean synchronous)
start() method).
resolution - The clock tick interval.target - Object to be sent tick notifications.synchronous - Flag controlling synchronous notification of clock
ticks. If true, notify synchronously; if false,
post notification on the message queue. Note that great care should
be taken with synchronous notification as it introduces threading
issues; do not use synchronous notification unless you understand
these issues thoroughly.
TickNoticer
public Clock every(long resolution,
TickNoticer target)
start() method). Clock ticks are always asynchronous: this method is
equivalent to the every(long,TickNoticer,boolean) method where
the synchronous argument is set to false.
resolution - The clock tick interval.target - Object to be sent tick notifications.
TickNoticerpublic static Timer theTimer()
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||