File tree 1 file changed +1
-1
lines changed
1 file changed +1
-1
lines changed Original file line number Diff line number Diff line change @@ -132,7 +132,7 @@ Java 线程在运行的生命周期中的指定时刻只可能处于下面 6 种
132
132
133
133
由上图可以看出:线程创建之后它将处于 ** NEW(新建)** 状态,调用 ` start() ` 方法后开始运行,线程这时候处于 ** READY(可运行)** 状态。可运行状态的线程获得了 CPU 时间片(timeslice)后就处于 ** RUNNING(运行)** 状态。
134
134
135
- > 在操作系统中层面线程有 READY 和 RUNNING 状态, 而在 JVM 层面只能看到 RUNNABLE 状态(图源:[ HowToDoInJava] ( https://howtodoinJava.com/ " HowToDoInJava ") :[ Java Thread Life Cycle and Thread States] ( https://howtodoinJava.com/Java/multi-threading/Java-thread-life-cycle-and-thread-states/ " Java Thread Life Cycle and Thread States ") ),所以 Java 系统一般将这两个状态统称为 ** RUNNABLE(运行中)** 状态 。
135
+ > 在操作系统层面,线程有 READY 和 RUNNING 状态; 而在 JVM 层面,只能看到 RUNNABLE 状态(图源:[ HowToDoInJava] ( https://howtodoinJava.com/ " HowToDoInJava ") :[ Java Thread Life Cycle and Thread States] ( https://howtodoinJava.com/Java/multi-threading/Java-thread-life-cycle-and-thread-states/ " Java Thread Life Cycle and Thread States ") ),所以 Java 系统一般将这两个状态统称为 ** RUNNABLE(运行中)** 状态 。
136
136
>
137
137
> ** 为什么 JVM 没有区分这两种状态呢?** (摘自:[ java线程运行怎么有第六种状态? - Dawell的回答] ( https://www.zhihu.com/question/56494969/answer/154053599 ) ) 现在的<b >时分</b >(time-sharing)<b >多任务</b >(multi-task)操作系统架构通常都是用所谓的“<b >时间分片</b >(time quantum or time slice)”方式进行<b >抢占式</b >(preemptive)轮转调度(round-robin式)。这个时间分片通常是很小的,一个线程一次最多只能在 CPU 上运行比如 10-20ms 的时间(此时处于 running 状态),也即大概只有 0.01 秒这一量级,时间片用后就要被切换下来放入调度队列的末尾等待再次调度。(也即回到 ready 状态)。线程切换的如此之快,区分这两种状态就没什么意义了。
138
138
You can’t perform that action at this time.
0 commit comments