Package io.github.amanzat.util
Class ThreadUtils
java.lang.Object
io.github.amanzat.util.ThreadUtils
Miscellaneous
Thread utility methods.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidsafeAcquire(Semaphore semaphore) Safely acquires a semaphore permit.static voidsafeAwait(CountDownLatch latch) Safely waits for the latch to count down to zero.static voidsafeSleep(long millis) Safely sleeps the current thread for the specified number of millis.
-
Constructor Details
-
ThreadUtils
public ThreadUtils()
-
-
Method Details
-
safeSleep
public static void safeSleep(long millis) Safely sleeps the current thread for the specified number of millis.- Parameters:
millis- The number of millis
-
safeAwait
Safely waits for the latch to count down to zero.- Parameters:
latch- The latch
-
safeAcquire
Safely acquires a semaphore permit.- Parameters:
semaphore- The semaphore
-