package cn.ruhsang.demo01;
//总结 线程开启不一定立即执行,由cpu调度执行
//创建县城方式一:继承Thread类,重新run方法
public class TestThread1 extends Thread{
@Override
public void run() {
//run方法线程体
for (int i = 0; i < 20; i++) {
System.out.println("我在看代码----"+i);
}
}
public static void main(String[] args) {
//创建一个线程对象
TestThread1 testThread1 = new TestThread1();
//调用start开启线程
testThread1.start();
//main线程,主线程
for (int i = 0; i < 2000 ; i++) {
System.out.println("我在学习多线程----"+i);
}
}
}
原文:https://www.cnblogs.com/nigustudent/p/14850878.html