public abstract class AbstractIntervalTimer extends Object implements Timer
AbstractIntervalTimer is common base class for Timer implementations that base measure the change in some value
between the point where the timer is started and the point where
the timer is stopped.
This class is thread-safe.
| Modifier and Type | Field and Description |
|---|---|
protected long |
cumulativeTime |
protected boolean |
running |
protected long |
startTime |
| Constructor and Description |
|---|
AbstractIntervalTimer() |
| Modifier and Type | Method and Description |
|---|---|
protected abstract long |
getCurrent() |
long |
getNanoseconds()
Get the number of nanoseconds that elapsed between when the
Timer was started and when it was stopped. |
protected double |
getRatio()
The fraction of the change in the underlying counter which will
be attributed to this timer.
|
void |
start()
Start the timer running.
|
void |
stop()
Stop the timer.
|
void |
update()
Update any internal state.
|
protected void |
update(long currentValue) |
protected boolean running
protected long startTime
protected long cumulativeTime
public void start()
Timerpublic void stop()
Timerpublic void update()
TimerTimer
implementations may take snapshots of data that may be
unavailable in the future. Clients should call this method
periodically to qensure that any state is being updated. For an
example, see JmxThreadGroupCpuTimer.update().public long getNanoseconds()
TimerTimer was started and when it was stopped. Note that the
return value has nanosecond precision but not necessarily
nanosecond accuracy.getNanoseconds in interface Timerprotected double getRatio()
protected void update(long currentValue)
protected abstract long getCurrent()
Copyright © 2022. All rights reserved.