Thread.sleep() 与 Thread.currentThread().sleep()区别到底是什么啊 ------最佳解决方案-------------------- 没有区别,你看下JDK的Thread.java实现就知道了。这个问题还在这里问....不该啊......送积分啊 ------其他解决方案-------------------- static void sleep(long millis)
在指定的毫秒数内让当前正在执行的线程休眠(暂停执行),此操作受到系统计时器和调度程序精度和准确性的影响。
static Thread currentThread()
返回对当前正在执行的线程对象的引用。
很明显没啥区别
其实还有一个类似的方法,就是java.util.concurrent下面的:
void sleep(long timeout)
使用此单元执行 Thread.sleep.这是将时间参数转换为 Thread.sleep 方法所需格式的便捷方法。 ------其他解决方案-------------------- javadoc说得相当明白了, sleep的方法的doc
/**
* Causes the currently executing thread to sleep (temporarily cease
* execution) for the specified number of milliseconds, subject to
* the precision and accuracy of system timers and schedulers. The thread
* does not lose ownership of any monitors.
*
* @param millis the length of time to sleep in milliseconds.
* @exception InterruptedException if any thread has interrupted
* the current thread. The <i>interrupted status</i> of the
* current thread is cleared when this exception is thrown.
* @see Object#notify()
*/