|
© 1998-2002 McGraw-Hill | |||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--structure.Clock
A simple object for measuring time. This Clock allows one to measure time between events. Events may be from several milliseconds to several seconds apart. When measuring events that take considerable time (> 1/10th of a second) it is important to counteract the effect of scheduling of other system processes. A Clock has the following operations:
Clock timer = new Clock(); timer.start()
; for (i = 0; i < 100000; i++); timer.stop()
; System.out.println("Time to count to 100000: "+timer.read()
+" seconds.");
Field Summary | |
protected long |
accum
The total number of milliseconds elapsed. |
protected boolean |
running
An indication of whether or not the clock is running |
protected long |
strt
The millisecond that the clock started. |
Constructor Summary | |
Clock()
Constructs a stopwatch for timing events to the milliseconds. |
Method Summary | |
double |
read()
Read the value on the stop watch. |
void |
reset()
Resets the time on the clock to zero. |
void |
start()
Start the clock running. |
void |
stop()
Stop the clock. |
String |
toString()
Generates string representation of clock. |
Methods inherited from class java.lang.Object |
|
Field Detail |
protected boolean running
protected long strt
protected long accum
Constructor Detail |
public Clock()
Method Detail |
public void start()
public void stop()
public double read()
public void reset()
public String toString()
toString
in class Object
|
© 1998-2002 McGraw-Hill | |||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |