/**
* 继承Thread类的线程
* @author LYWZL
*
*/
public class ThreadTest {
public static void main(String[] args) {
MyThread1 mtd = new MyThread1();
mtd.start();
Thread.currentThread().setName("我是主线程");
for (int i = 0; i < 50; i++) {
System.out.println(Thread.currentThread().getName()+"第"+i+"次运行");
}
}
}
class MyThread1 extends Thread{
@Override
public void run() {
Thread.currentThread().setName("我是子线程");
for (int i = 0; i < 50; i++) {
System.out.println(Thread.currentThread().getName()+"第"+i+"次运行");
}
}
}