Class ThreadHandler


  • public final class ThreadHandler
    extends java.lang.Object
    ThreadHandler is a common pattern used to control the safe handling of a sleeping thread.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static void safeSleep​(long millis)
      Sleep for the requested number of milliseconds
      static boolean sleepUntil​(java.time.Instant wakeUpTime)
      Sleep until we reach the target wakeUpTime
      • Methods inherited from class java.lang.Object

        clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • 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