Class SleepUtils
java.lang.Object
net.emustudio.emulib.SleepUtils
Precise sleeping.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final longAverage duration ofThread.sleep(1)in nanoseconds (measured when the class is loaded). -
Method Summary
Modifier and TypeMethodDescriptionstatic voidpreciseSleepNanos(long nanoDuration) Accurately sleeps on all platforms (Linux, Win, Mac); more precise thanLockSupport.parkNanos.
-
Field Details
-
SLEEP_PRECISION
public static final long SLEEP_PRECISIONAverage duration ofThread.sleep(1)in nanoseconds (measured when the class is loaded).
-
-
Method Details
-
preciseSleepNanos
public static void preciseSleepNanos(long nanoDuration) Accurately sleeps on all platforms (Linux, Win, Mac); more precise thanLockSupport.parkNanos.Sleeps while the remaining time exceeds
SLEEP_PRECISION, then spin-waits. Returns early if the thread is interrupted (the interrupt flag is kept). See alternative to Thread.sleep.- Parameters:
nanoDuration- nanoseconds
-