Skip to content

Commit

Permalink
[docs update]增加状态
Browse files Browse the repository at this point in the history
  • Loading branch information
1020325258 committed Dec 29, 2024
1 parent d6eca60 commit 330d1dc
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions docs/java/concurrent/java-concurrent-questions-03.md
Original file line number Diff line number Diff line change
Expand Up @@ -365,8 +365,10 @@ public void allowCoreThreadTimeOut(boolean value) {

核心线程空闲时,其状态分为以下两种情况:

- **设置了核心线程的存活时间** :核心线程在空闲时,会处于阻塞状态,等待获取任务。如果阻塞等待的时间超过了核心线程存活时间,则该线程会退出工作,之后将该线程从线程池的工作线程集合中移除。
- **没有设置核心线程的存活时间** :核心线程在空闲时,会一直处于阻塞状态,等待获取任务。
- **设置了核心线程的存活时间** :核心线程在空闲时,会处于 `WAITING` 状态,等待获取任务。如果阻塞等待的时间超过了核心线程存活时间,则该线程会退出工作,将该线程从线程池的工作线程集合中移除,线程状态变为 `TERMINATED` 状态。
- **没有设置核心线程的存活时间** :核心线程在空闲时,会处于 `WAITING` 状态,等待获取任务。

当核心线程获取任务之后,会由 `WAITING` 状态变为 `RUNNABLE` 状态,之后去执行对应任务。

#### 相关源码

Expand Down

0 comments on commit 330d1dc

Please sign in to comment.