@NotThreadSafe public final class SleepingTimer extends Object implements HeartbeatTimer
Constructor and Description |
---|
SleepingTimer(String threadName,
long intervalMs)
Creates a new instance of
SleepingTimer . |
SleepingTimer(String threadName,
long intervalMs,
org.slf4j.Logger logger,
java.time.Clock clock,
Sleeper sleeper)
Creates a new instance of
SleepingTimer . |
Modifier and Type | Method and Description |
---|---|
void |
setIntervalMs(long intervalMs)
Sets the heartbeat interval.
|
void |
tick()
Enforces the thread waits for the given interval between consecutive ticks.
|
public SleepingTimer(String threadName, long intervalMs)
SleepingTimer
.threadName
- the thread nameintervalMs
- the heartbeat intervalpublic SleepingTimer(String threadName, long intervalMs, org.slf4j.Logger logger, java.time.Clock clock, Sleeper sleeper)
SleepingTimer
.threadName
- the thread nameintervalMs
- the heartbeat intervallogger
- the logger to log toclock
- for telling the current timesleeper
- the utility to use for sleepingpublic void setIntervalMs(long intervalMs)
HeartbeatTimer
setIntervalMs
in interface HeartbeatTimer
intervalMs
- the heartbeat interval in mspublic void tick() throws InterruptedException
tick
in interface HeartbeatTimer
InterruptedException
- if the thread is interrupted while waitingCopyright © 2023. All Rights Reserved.