//继承Thread类,重写润()方法,调用start开启线程 public class TestThread extends Thread { @Override public void run() { //run方法线程体 for (int i = 0; i < 20; i++) { System.out.println("学习1" + i); } } public void main(String[] args) { //main线程,主线程 //创建一个线程对象 TestThread testThread = new TestThread(); //调用start方法() 开启线程 testThread.start(); for (int i = 0; i < 2000; i++) { System.out.println("学习" + i); } } } }
多线程于进程
最新推荐文章于 2024-05-08 15:24:52 发布