Class SleepUtils

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

      Constructor Description
    • 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


        public static final long SLEEP_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

        nanoDuration - nanoseconds