@ThreadSafe public final class ScheduledTimer extends Object implements HeartbeatTimer
ScheduledTimer
blocks on the tick()
method, waiting for
someone to invoke the schedule()
method.
The contract of this class is that the schedule()
method should only be called after the
tick()
was called and that there is exactly one schedule()
call per
tick()
call.
The schedule()
method is not meant to be invoked directly. Instead, the
HeartbeatScheduler
class should be used.Constructor and Description |
---|
ScheduledTimer(String threadName,
long intervalMs)
Creates a new instance of
ScheduledTimer . |
Modifier and Type | Method and Description |
---|---|
String |
getThreadName() |
protected void |
schedule()
Schedules execution of the heartbeat.
|
void |
tick()
Waits until next heartbeat should be executed.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getIntervalMs, setIntervalMs
public ScheduledTimer(String threadName, long intervalMs)
ScheduledTimer
.threadName
- the thread nameintervalMs
- the heartbeat interval (unused)public String getThreadName()
protected void schedule()
public void tick() throws InterruptedException
HeartbeatTimer
tick
in interface HeartbeatTimer
InterruptedException
- if the thread is interrupted while waitingCopyright © 2023. All Rights Reserved.