1
public class Ztest {
public static void main(String[] args) {
MyThread thread=new MyThread();
thread.start();//启动线程
for(int i=0;i<1000;i++) {
System.out.println(“mainThread:”+i);
}}}
2
public class MyThread extends Thread {
@Override
public void run() {
for(int i=0;i<1000;i++) {
System.out.println(“MyThread:”+i);
}
}
}
结果:
创建线程
最新推荐文章于 2023-02-03 07:00:00 发布