|
|||||||||
| Home >> All >> iiuf >> [ util overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
iiuf.util
Class Timer

java.lang.Objectiiuf.util.Timer
- All Implemented Interfaces:
- java.lang.Runnable, java.io.Serializable
- Direct Known Subclasses:
- TestTimer
- public class Timer
- extends java.lang.Object
- implements java.lang.Runnable, java.io.Serializable
- extends java.lang.Object
The timer class. This class implements timer tasks that can be run at a specified time. This class stores tasks in an efficient tree representation which keeps the insert and remove costs almost constant even for a large (> 10000) number of tasks. (c) 1999, 2000, 2001, IIUF, DIUF
- Version:
- $Revision: 1.1 $
| Field Summary | |
long |
absolute
|
(package private) boolean |
dontRun
If true, the timer's run will not be called. |
protected boolean |
execute
Set to true as soon as the run method
starts executing. |
long |
milliseconds
|
protected Timer |
next
The link to the next timer. |
private static java.util.Random |
random
|
protected boolean |
thread
|
private java.lang.Runnable |
timer_task
The task to run by this timer, or null if no task. |
| Constructor Summary | |
protected |
Timer()
|
protected |
Timer(boolean thread_)
|
|
Timer(java.lang.Runnable timer_task_,
boolean thread)
Creates a new timer task. |
| Method Summary | |
Timer |
cancel()
Cancels this timer. |
private static void |
countdown(int sec)
|
static void |
main(java.lang.String[] argv)
Test program. |
Timer |
reschedule()
Re-schedules this objects run method to be executed in
milliseconds_ after the schedule call from the
last execution of the run method. |
private static int |
rnd(int range)
|
void |
run()
This method will be called by whoever wishes to run your class implementing Runnable. |
Timer |
schedule(long milliseconds_)
Schedules this objects run method to be executed in
milliseconds_ from now. |
java.lang.String |
toString()
Convert this Object to a human-readable String. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
milliseconds
public long milliseconds
absolute
public long absolute
next
protected transient Timer next
- The link to the next timer.
execute
protected transient boolean execute
- Set to
trueas soon as therunmethod starts executing. reset byrescheduleorschedule.
thread
protected boolean thread
timer_task
private transient java.lang.Runnable timer_task
- The task to run by this timer, or
nullif no task.
dontRun
transient boolean dontRun
- If
true, the timer'srunwill not be called. This variable is set to false byTimerTree.insert()and set byTimerTree.remove().
random
private static java.util.Random random
| Constructor Detail |
Timer
protected Timer()
Timer
protected Timer(boolean thread_)
Timer
public Timer(java.lang.Runnable timer_task_, boolean thread)
- Creates a new timer task.
| Method Detail |
schedule
public Timer schedule(long milliseconds_)
- Schedules this objects
runmethod to be executed inmilliseconds_from now.
cancel
public Timer cancel()
- Cancels this timer. Cancel only ensures that the
runmethod is not executed aftercancelreturns. But therunmethod may be excuted during the execution ofcancel.
reschedule
public Timer reschedule()
- Re-schedules this objects
runmethod to be executed inmilliseconds_after theschedulecall from the last execution of therunmethod. Use this call for fixed frequency tasks instead of usingschedulein order to avoid drift.
toString
public java.lang.String toString()
- Description copied from class:
java.lang.Object - Convert this Object to a human-readable String.
There are no limits placed on how long this String
should be or what it should contain. We suggest you
make it as intuitive as possible to be able to place
it into System.out.println() 55
and such.
It is typical, but not required, to ensure that this method never completes abruptly with a java.lang.RuntimeException.
This method will be called when performing string concatenation with this object. If the result is
null, string concatenation will instead use"null".The default implementation returns
getClass().getName() + "@" + Integer.toHexString(hashCode()).
run
public void run()
- Description copied from interface:
java.lang.Runnable - This method will be called by whoever wishes to run your class
implementing Runnable. Note that there are no restrictions on what
you are allowed to do in the run method, except that you cannot
throw a checked exception.
- Specified by:
runin interfacejava.lang.Runnable
rnd
private static int rnd(int range)
countdown
private static void countdown(int sec)
main
public static void main(java.lang.String[] argv)
- Test program.
|
|||||||||
| Home >> All >> iiuf >> [ util overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
JAVADOC
iiuf.util.Timer