0

既然 Thread.sleep(long mills, int nanos) 的两个参数是用来定义超时时间的。为什么我们需要第二个参数呢?我们是不是直接调用 Thread.sleep(long mills) 并增加它的参数值?如果不是,那是什么?有两个参数的特殊点?

4

2 回答 2

6

The purpose of the two-argument Thread.sleep() is to allow you to specify sleep times in submillisecond intervals on systems that support that kind of resolution.

There would be no way to specify, e.g. a half a millisecond (500,000 nanoseconds) otherwise.

于 2013-11-15T08:32:26.053 回答
0

a nano is less than a milli so this allows for more precision

于 2013-11-15T08:32:29.247 回答