保存在内存中了。没有本质的区别,不同的是 new NewThread() 是一个匿名对象引用。

解决方案 »

  1.   

    改为new Thread()后,这样也行哦。
    class NewThread implements Runnable{
    String name;//name of the thread

    NewThread(String threadname){
    name=threadname;
    new Thread(this,name).start();//start the thread
    }

    public void run(){
    try{
    for(int i=5;i>0;i--){
    System.out.println(name+":"+i);
    Thread.sleep(1000);
    }
    }catch(InterruptedException e){
    System.out.println(name+"interrupted.");
    }
    System.out.println(name+"Exiting.");
    }
    }
      

  2.   

    new NewThread() 创建了一个匿名对象,所以在创建之后你无法再对其进行操作。
    NewThread ob1=new NewThread(); 你持有一个ob1的引用,因此可以对其进行操作
      

  3.   

    匿名的线程对象很特殊,虽然不再被引用,但是仍然不会被垃圾收集程序所回收,知道该线程的run方法执行完毕
      

  4.   

    NewThread ob1=new NewThread(); 相当于给对象起了个名字,通过它对对象进行操作。
    new NewThread() 是无法进行操作的,当他超出定义的范围(scope)时,就会成为垃圾,等待gc的回收。
    :)