I am reading about class Object and I found a method wait(long timeout, int nanos).
I read a description Docs Oracle Class Object and I found that:
The amount of real time, measured in nanoseconds, is given by:
1000000*timeout+nanosParameters:
timeout - the maximum time to wait in milliseconds.
nanos - additional time, in nanoseconds range 0-999999.
I took a look at implementation of this method (openjdk-7u40-fcs-src-b43-26_aug_2013) and I found this piece of code:
public final void wait(long timeout, int nanos) throws InterruptedException {
if (timeout < 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 && timeout == 0)) {
timeout++;
}
wait(timeout);
}
First and second ifs are obvious. Third one does nothing or just increments timeout and does not care about nanos.
My question is, how I can invoke method wait(long timeout, int nanos) which really works with given nanos?
Thank you in advance