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);
}
}
}
结果:
创建线程

相关文章:

  • 2022-02-09
  • 2021-12-18
  • 2021-12-13
  • 2022-12-23
  • 2022-12-23
  • 2021-11-01
  • 2022-01-01
  • 2021-05-11
猜你喜欢
  • 2021-10-01
  • 2022-01-13
  • 2021-04-07
  • 2021-10-10
相关资源
相似解决方案