技术问答-26 线程的状态 新建 准备 运行 休眠 停止
package com.test;public class Test {public static void main(String[] args) {//(1)新建 Thread t = new Thread(new MyRunnablee());//(2)就绪 等待CPU t.start();}}class MyRunnablee implements Runnable{public void run() {//(3)开始执行 System.out.println("运行状态开始");for(int i=0;i<10;i++) {try {//(4)休眠状态 Thread.sleep(1000); System.out.println("执行run"+i);} catch (InterruptedException e) { e.printStackTrace();}} System.out.println("运行状态结束");//(5)执行完run之后 就结束状态了}}