Java 线程始终处于以下十种状态之一:
NEW: Just starting up, i.e., in process of being initialized.
NEW_TRANS: Corresponding transition state (not used, included for completness).
IN_NATIVE: Running in native code.
IN_NATIVE_TRANS: Corresponding transition state.
IN_VM: Running in VM.
IN_VM_TRANS: Corresponding transition state.
IN_JAVA: Running in Java or in stub code.
IN_JAVA_TRANS: Corresponding transition state (not used, included for completness).
BLOCKED: Blocked in vm.
BLOCKED_TRANS: Corresponding transition state.
未使用的状态 ( UNINITIALIZED
) 已从列表中省略。
虽然上面给出了状态的定义,但我正在寻找“经验法则”来解释正在运行的应用服务器的给定线程状态设置。而且,更具体地说:
假设一个实时应用服务器在不同时间点具有以下线程统计信息(使用jstack获得):
- 100 线程: 35
BLOCKED
, 65IN_NATIVE
- 113 线程: 35
BLOCKED
, 77IN_NATIVE
, 1IN_VM
- 52 线程: 38
BLOCKED
, 1IN_JAVA
, 6IN_NATIVE
, 7IN_VM
- 120 线程
BLOCKED
:IN_JAVA
39、1、80IN_NATIVE
- 94 线程:
BLOCKED
34、59、1IN_NATIVE
IN_NATIVE_TRANS
对于五个统计数据中的每个线程 - 关于整个 JVM 状态可以推断出什么?即“在这种情况下,JVM 看起来正在空闲等待请求”,“机器正忙于处理请求”等。