Java中執行緒的狀態型別
執行緒的狀態型別
原始碼作者的原注釋關于執行緒內部類
State描述了執行緒的六個狀態
- A thread state. A thread can be in one of the following states:
①、NEW
- 尚未啟動的執行緒處于此狀態
- 原始碼中的注釋
A thread that has not yet started is in this state.
②、RUNNABLE
- 在Java虛擬機中執行的執行緒處于這種狀態
- 原始碼中的注釋
A thread executing in the Java virtual machine is in this state.
③、BLOCKED
- 被組織等待監視器鎖定的執行緒處于此狀態
- 原始碼中的注釋
A thread that is blocked waiting for a monitor lock is in this state.
④、WATING
- 無限期等待另一個執行緒執行特定操作的執行緒處于此狀態
- 原始碼中的注釋
A thread that is waiting indefinitely for another thread to perform a particular action is in this state.
⑤、TIMED_WATING
-
一個執行緒等待另一個執行緒執行操作,在指定的等待時間內處于此狀態
-
原始碼中的注釋
A thread that is waiting for another thread to perform an action for up to a specified waiting time is in this state
⑥、TERMINATED
- 已退出的執行緒處于此狀態
- 原始碼中的注釋
A thread that has exited is in this state.
小結
- 可以用一個列舉類來說明執行緒的這幾個狀態
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/501166.html
標籤:其他
