Java中線程的狀態類型 線程的狀態類型 源碼作者的原註釋關於線程內部類State描述了線程的六個狀態 A thread state. A thread can be in one of the following states: ①、NEW 尚未啟動的線程處於此狀態 源碼中的註釋 A thread ...
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.
小結
- 可以用一個枚舉類來說明線程的這幾個狀態