不可能的。不会是你看错了吧?:)
或者是你把sleep()方法中的参数改为4990了。

解决方案 »

  1.   

    这是JDK documents 里对System.currentTimeMillis()的返回值的说明
    Returns the current time in milliseconds. Note that while the unit of time of the return value is a millisecond, the granularity of the value depends on the underlying operating system and may be larger. For example, many operating systems measure time in units of tens of milliseconds. 
    设成5000毫秒,在我的机器上一般总是得到4997,做个实验,如果设成5003,则,结果一般总是5007,有时候5006.如果设成5005,则,结果一般还是5007,如果设成5009,则,结果一般总是5017。大致总是差10毫秒。就像帮助文档里说的一样。很多系统是只能精确到10毫秒的。
      

  2.   

    '精确也是应该大于5000的基础上又偏差10左右呀'???
    你为什么这样认为呢?是不是被原文中may be larger迷惑了?
    原文中may be larger是指我的例子中5003返回5007的情况,不郁闷了吧?
      

  3.   

    Thread.sleep();本身就是不精确的时间。所以偏差是肯定的
      

  4.   

    Monitor从新启动这个线程本来就是应该大于线程sleep的时间,我那个例子是肯定应该大于5000的,我郁闷的是为什么会出现4997这个小于5000的结果.难道说先得到startSleepTime,让后在try中sleep时需要花费一定的时间(好像只能这么解释了,谁还有高见).
      

  5.   

    我不是说得很清楚了么,线程sleep的时间根本就不是5000,sleep不是精确的,sleep(5000)可能实际上只sleep(4994),但也可能sleep(5004),而且currentTimeMillis也不是精确的,如果实际时间是80000,返回值可能是79995也可能是80003,这两个方法都不精确,结果怎么能精确?就算是计算机时钟也只能有一个最小分辨值的,根本没有任何东西是能精确到你的理想情况的,但你总以理想的情况去分析一个不精确的结果.结账吧