Class ThreadUtils


  • public final class ThreadUtils
    extends java.lang.Object
    Helps work with threads.
    Since:
    2.12.0
    • Constructor Summary

      Constructors 
      Constructor Description
      ThreadUtils()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static void sleep​(java.time.Duration duration)
      Sleeps for a guaranteed minimum duration unless interrupted.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • ThreadUtils

        public ThreadUtils()
    • Method Detail

      • sleep

        public static void sleep​(java.time.Duration duration)
                          throws java.lang.InterruptedException
        Sleeps for a guaranteed minimum duration unless interrupted.

        This method exists because Thread.sleep(100) can sleep for 0, 70, 100 or 200ms or anything else it deems appropriate. Read Thread.sleep(long, int)} for further interesting details.

        Parameters:
        duration - the sleep duration.
        Throws:
        java.lang.InterruptedException - if interrupted
        See Also:
        Thread.sleep(long, int)