package testThread;
//创建线程方式一:继承Thread类 ,重写run()方法,调用start开启线程
//线程开启不一定马上执行,但是run()一定马上执行,线程由CPU决定什么时候调用
public class TestThread extends Thread {
@Override
public void run(){
//run方法线程体
for (int i = 0; i < 20;i++){
System.out.println("我在学代码---"+i);
}
}
public static void main(String[] args) {
//main线程,主线程
//创建一个线程对象
TestThread testThread = new TestThread();
//调用start()方法开启线程
testThread.start();
for (int i =0;i <20;i++){
System.out.println("我在学习多线程"+i);
}
}
}