没有区别,你看下JDK的Thread.java实现就知道了。这个问题还在这里问....不该啊......送积分啊

解决方案 »

  1.   

    static void sleep(long millis) 
              在指定的毫秒数内让当前正在执行的线程休眠(暂停执行),此操作受到系统计时器和调度程序精度和准确性的影响。 
    static Thread currentThread() 
              返回对当前正在执行的线程对象的引用。 
    很明显没啥区别
    其实还有一个类似的方法,就是java.util.concurrent下面的:
     void sleep(long timeout) 
              使用此单元执行 Thread.sleep.这是将时间参数转换为 Thread.sleep 方法所需格式的便捷方法。 
      

  2.   

    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()
         */其实类似的还有好多, 例如Class.getResourceAsStream和ClassLoader.getResourceAsStream, 功能一样, 只是寻找的方法有点不一样而已
      

  3.   

    区别当然是有了。第一种方式是只调用sleep静态方法;第二种是获取对象后再调用sleep静态方法。显然第二种方式效率要低一些,因为多了一次函数调用,而且通过对象调用静态方法也不太符合“静态”的定义(静态成员最好通过类名直接访问),但功能上是一致的。当需要调用非静态方法时使用第二种方式,否则直接使用第一种方式。
      

  4.   

    sleep方法是静态的,执行的结果是一样的。但是第二种写法画蛇添足,也不符合规范。
      

  5.   

     /**
         * 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()
         */
        public static native void sleep(long millis) throws InterruptedException; /**
         * Returns a reference to the currently executing thread object.
         *
         * @return  the currently executing thread.
         */
        public static native Thread currentThread();
       就是同一个对象,当你起一个main单线程的时候,就可以很容易发觉,你无论 currentThread();
    还是Thread,线程根本不会变多。跟简单点说。 public static void main(String args[]) {
    System.out.println(Thread.activeCount());
    System.out.println(Thread.currentThread().getId());
    System.out.println(Thread.activeCount());

    输出都是1
      

  6.   

    线程可以用继承Thread类或者实现Runnable接口来实现.
    Thread.sleep()是Thread类的方法,只对当前线程起作用,睡眠一段时间.
    如果线程是通过继承Thread实现的话这2个方法没有区别;
    如果线程是通过实现Runnable接口来实现的,则不是Thread类,不能直接使用Thread.sleep()
    必须使用Thread.currentThread()来得到当前线程的引用才可以调用sleep(),
    所以要用Thread.currentThread().sleep()来睡眠...
      

  7.   

    如果线程是通过实现Runnable接口来实现的,则不是Thread类,不能直接使用Thread.sleep()
    为什么?sleep()不是Thread类的静态方法么,为什么在实现不继承Thread就不能直接调用它的sleep()方法?