Class ThreadUtils

java.lang.Object
io.github.amanzat.util.ThreadUtils

public final class ThreadUtils extends Object
Miscellaneous Thread utility methods.
  • 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

      public static void safeAwait(CountDownLatch latch)
      Safely waits for the latch to count down to zero.
      Parameters:
      latch - The latch
    • safeAcquire

      public static void safeAcquire(Semaphore semaphore)
      Safely acquires a semaphore permit.
      Parameters:
      semaphore - The semaphore