一: Java的线程一共有6种状态,这是来自java官方源代码里面定义的,是最权威的。
- NEW
- RUNNABLE
- BLOCKED
- WAITING
- TIMED_WAITING
- TERMINATED
二: 如何查看源码: 输入以下代码,在IntelliJ Idea中按快捷键ctrl+B
Thread.State
三: A thread state.
- {@link #NEW}
A thread that has not yet started is in this state. - {@link #RUNNABLE}
A thread executing in the Java virtual machine is in this state. - {@link #BLOCKED}
A thread that is blocked waiting for a monitor lock is in this state. - {@link #WAITING}
A thread that is waiting indefinitely for another thread to perform a particular action is in this state. - {@link #TIMED_WAITING}
A thread that is waiting for another thread to perform an action for up to a specified waiting time is in this state. - {@link #TERMINATED}
A thread that has exited is in this state.
A thread can be in one of the following states: