Class ThreadHandler
- java.lang.Object
-
- org.linuxforhealth.fhir.database.utils.thread.ThreadHandler
-
public final class ThreadHandler extends java.lang.Object
ThreadHandler is a common pattern used to control the safe handling of a sleeping thread.
-
-
Field Summary
Fields Modifier and Type Field Description static long
FIVE_SECONDS
static long
MINUTE
static long
SECOND
static long
TEN_SECONDS
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static void
safeSleep(long millis)
Sleep for the requested number of millisecondsstatic boolean
sleepUntil(java.time.Instant wakeUpTime)
Sleep until we reach the target wakeUpTime
-
-
-
Field Detail
-
SECOND
public static final long SECOND
- See Also:
- Constant Field Values
-
FIVE_SECONDS
public static final long FIVE_SECONDS
- See Also:
- Constant Field Values
-
TEN_SECONDS
public static final long TEN_SECONDS
- See Also:
- Constant Field Values
-
MINUTE
public static final long MINUTE
- See Also:
- Constant Field Values
-
-
Method Detail
-
safeSleep
public static void safeSleep(long millis)
Sleep for the requested number of milliseconds- Parameters:
millis
-
-
sleepUntil
public static boolean sleepUntil(java.time.Instant wakeUpTime)
Sleep until we reach the target wakeUpTime- Parameters:
wakeUpTime
-- Returns:
- true if we woke up naturally, false if our sleep was interrupted
-
-