
简单说,wait(long timeout, int nanos)方法提供比wait(long timeout)更好的时间控制
1ms= 1000 000ns ,其中wait的timeout都是ms单位
This method is similar to the wait method of one argument, but it allows finer control over the amount of time to wait for a notification before giving up. The amount of real time, measured in nanoseconds, is given by:
你的代码是jdk?版本,我的jdk6 有段显示跟你不太一样:
if (nanos >= 500000 || (nanos != 0 && timeout == 0)) {
timeout++;
}
wait(timeout);
