What's the purpose of sleep(long millis, int nanos)?

Viewed 5087

In the JDK, it's implemented as:

public static void sleep(long millis, int nanos) 
throws InterruptedException {
if (millis < 0) {
        throw new IllegalArgumentException("timeout value is negative");
}

if (nanos < 0 || nanos > 999999) {
        throw new IllegalArgumentException(
            "nanosecond timeout value out of range");
}

if (nanos >= 500000 || (nanos != 0 && millis == 0)) {
    millis++;
}

sleep(millis);
}

which means the nanos argument doesn't do anything at all.

Is the idea behind it that on hardware with more accurate timing, the JVM for it can provide a better implementation for it?

3 Answers
Related