public class Xxx
{
public static void main(String args[])
{
new Test().start();
for(int i=0;i<10;i++)
{
System.out.println(Thread.currentThread()+"main线程在运行");
}
}
}
class Test extends Thread
{
public void run()
{
for(int i=0;i<10;i++)
{
System.out.println(Thread.currentThread()+"Text running");
}
}
}
/*
我运行就可以啊,你可以线程名称或者让循环多转一会。
没加名称:
main线程在运行
main线程在运行
main线程在运行
main线程在运行
main线程在运行
main线程在运行
main线程在运行
main线程在运行
main线程在运行
main线程在运行
Text running
Text running
Text running
Text running
Text running
Text running
Text running
Text running
Text running
Text running
加了名称:
Thread[Thread-0,5,main]Text running
Thread[Thread-0,5,main]Text running
Thread[Thread-0,5,main]Text running
Thread[Thread-0,5,main]Text running
Thread[Thread-0,5,main]Text running
Thread[Thread-0,5,main]Text running
Thread[Thread-0,5,main]Text running
Thread[Thread-0,5,main]Text running
Thread[Thread-0,5,main]Text running
Thread[Thread-0,5,main]Text running
Thread[main,5,main]main线程在运行
Thread[main,5,main]main线程在运行
Thread[main,5,main]main线程在运行
Thread[main,5,main]main线程在运行
Thread[main,5,main]main线程在运行
Thread[main,5,main]main线程在运行
Thread[main,5,main]main线程在运行
Thread[main,5,main]main线程在运行
Thread[main,5,main]main线程在运行
Thread[main,5,main]main线程在运行
*/ |