public class TestThread1 extends Thread{//自定义线程类继承Thread类
@Override
public void run(){//重写run()方法,编写线程执行体
//run方法线程体
for (int i = 0; i < 50; i++) {
System.out.println("TestThread1线程在执行");
}
}
public static void main(String[] args) {
//main线程,主线程
//创建一个线程对象
TestThread1 testThread1 = new TestThread1();
//调用start()方法开启线程
testThread1.start();
for (int i = 0; i < 200; i++) {
System.out.println("main函数中的主线程在执行");
}
}
}