class Test extends Thread
{
private String name;
Test(String name)
{
super(name);
//this.name=name;
}
public void run()
{
System.out.println(this.getName()+"--run----");
}
}
class ThreadTest
{
public static void main(String[] args)
{
Test t1=new Test("first");
Test t2=new Test("two");
t1.start();
t2.start();
}
}
请问,为什么用super(name);可以打印出所设置的名字,而用this.name=name;就打印不出来呢?求解!! |
|