System.out.println(new Date().getTime());
Thread.sleep(1000,100000);//此时毫秒数+1
System.out.println(new Date().getTime());
输出:
1538202362532
1538202363532
睡眠时间:mills+nanos,并且nanos有大小限制,也会“进位”。sleep不会释放锁。
注释很重要!
java1.8源码:
/**
* Causes the currently executing thread to sleep (temporarily cease
* execution) for the specified number of milliseconds plus the specified
* number of nanoseconds, subject to the precision and accuracy of system
* timers and schedulers. The thread does not lose ownership of any
* monitors.
*
* @param millis