请问 Thread.currentThread();
Thread.sleep(5000);和 Thread.sleep(5000); 区别在哪里?

解决方案 »

  1.   

    currentThread返回现在执行的线程。
    你这么些应该没有区别吧。
      

  2.   

    sleep是一个静态方法,应该使用Thread.sleep(5000); 
    而不是Thread.currentThread().sleep(); 
    不管用哪种方式,它都是让当前线程睡眠
    还有1.5后可以使用TimeUnit.SECONDS.sleep(5);
      

  3.   

    没什么区别啊
    Thread.currentThread()返回对当前正在执行的线程对象的引用。
    但是sleep方法是静态的方法,用Thread这个类就可以直接调用了。
      

  4.   


    嘴疼[color=#FFFFFF][/color]
      

  5.   

    public static native void sleep(long millis) throws InterruptedException;
    Causes the currently executing thread to sleep所以这个sleep总是让当前线程暂停指定时间,而且是静态方法。
      

  6.   

    sleep(5000)到底是让哪个线程睡眠,
    取决于是哪个线程执行了这个sleep(5000)语句;
    而不取决于你调用了哪个线程对象的sleep(5000)方法;
      

  7.   

    一个Thread 对象就是一个线程。
      

  8.   

    Thread.sleep(5000); 
    就是让当前线程休眠5秒