class ThreadDemo
{
public static void main(String[] args)
{
ThreadTest t1 = new ThreadTest("one--");
ThreadTest t2 = new ThreadTest("two--");
t1.start();
t2.start();
for(int x=0;x<=60;x++)
{
System.out.println("main");
}
}
}
class ThreadTest extends Thread
{
private String name;
ThreadTest(String name)
{
this.name = name;
}
public void run()
{
for(int x=0;x<=60;x++)
{
System.out.println(this.getName());
}
}
}
线程有个可以打印线程名字的方法,我调用了打印的都是现成的默认名字,
而我设定的名字没有打印出来,
能告诉我是怎么回事吗?
|