Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static void sleepNanos (long nanoDuration) throws InterruptedException {
- final long end = System.nanoTime() + nanoDuration;
- long timeLeft = nanoDuration;
- do {
- if (timeLeft > SLEEP_PRECISION)
- Thread.sleep (1);
- else
- if (timeLeft > SPIN_YIELD_PRECISION)
- Thread.yield();
- timeLeft = end - System.nanoTime();
- } while (timeLeft > 0);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement