Class SleepUtils


  • public class SleepUtils
    extends java.lang.Object
    Sleeping and time measurement utilities.
    • Constructor Summary

      Constructors 
      Constructor Description
      SleepUtils()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static void preciseSleepNanos​(long nanoDuration)
      Accurately sleeps on all platforms (Linux, Win, Mac).
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • SLEEP_PRECISION

        public static final long SLEEP_PRECISION
      • SPIN_YIELD_PRECISION

        public static final long SPIN_YIELD_PRECISION
    • Constructor Detail

      • SleepUtils

        public SleepUtils()
    • Method Detail

      • preciseSleepNanos

        public static void preciseSleepNanos​(long nanoDuration)
        Accurately sleeps on all platforms (Linux, Win, Mac). Sleep precision: SLEEP_PRECISION (determined automatically)

        It is more precise than LockSupport::sleepNanos

        See: - accurate sleep for java - alternative to Thread.sleep

        Parameters:
        nanoDuration - nanoseconds