运行的结果是
child thread:thread[demo Thread,5,main]
main thread:5
child thread:5
child thread:4
main thread:4
child thread:3
child thread:2
main thead:3
child thread:1
exiting child thread.
main thread:2
main thread:1
main thread exiting

解决方案 »

  1.   

    NewThread本身就是一个线程呀!
    只不过newThread是由ThreadDemo控制
      

  2.   

    main()是主线程
    newThread 是子线程,当然是两个线程了
      

  3.   

    同意楼上的,main()是主线程
    newThread 是子线程,当然是两个线程了你只看到一次 new Thread(); 
    是的,那是你生成的Thread, 但是别忘了主线程(main())也是一个线程呀。可能你是初学者,我写了一个例子,可以运行的。package csdn;public class MyClass7 {  public MyClass7() {
      }  public static void main(String[] args) {
        MyClass7 myClass7 = new MyClass7();
        myClass7.invokedStandalone = true;    MyClass7_NewThread t0=new MyClass7_NewThread(" Thread First ");
        MyClass7_NewThread t1=new MyClass7_NewThread(" Thread Second ");
      }
      private boolean invokedStandalone = false;
    }
    class MyClass7_NewThread implements Runnable
    {
    Thread t;
    MyClass7_NewThread(String threadName){
    t=new Thread(this,threadName);
    System.out.println(threadName+" starting .... " );
    t.start();
    }
    public void run()
    {
    try{
    for(int i=5;i>0;i--){
    System.out.println(t.getName()+" "+i);
    Thread.sleep(500);
    }
    }
    catch(InterruptedException e){
    System.out.println(t.getName ()+"interrupted.");
    }
    System.out.println("Exiting "+t.getName ());
    }
    }你会明白些。:》