Modifier and Type | Field and Description |
---|---|
static SteppingThreadSleeper |
INSTANCE |
Constructor and Description |
---|
SteppingThreadSleeper(Sleeper internalSleeper,
java.time.Clock clock)
Creates a new instance of
SteppingThreadSleeper . |
Modifier and Type | Method and Description |
---|---|
void |
setSleepStepMs(long sleepStepMs)
Sets the sleep step.
|
void |
sleep(java.time.Duration duration)
Sleeps for the given duration.
|
void |
sleep(java.util.function.Supplier<java.time.Duration> durationSupplier)
Sleeps for given duration but period wake-up by new interval supplier.
|
public static final SteppingThreadSleeper INSTANCE
public SteppingThreadSleeper(Sleeper internalSleeper, java.time.Clock clock)
SteppingThreadSleeper
.internalSleeper
- the internal sleeperclock
- for telling the current timepublic void sleep(java.time.Duration duration) throws InterruptedException
Sleeper
sleep
in interface Sleeper
duration
- the duration to sleep forInterruptedException
- if the sleep is interruptedpublic void sleep(java.util.function.Supplier<java.time.Duration> durationSupplier) throws InterruptedException
Sleeper
sleep
in interface Sleeper
durationSupplier
- New sleep interval supplierInterruptedException
public void setSleepStepMs(long sleepStepMs)
sleepStepMs
- the sleep stepCopyright © 2023. All Rights Reserved.