java thread 运行状态,Java线程:解释正在运行的JVM的线程状态

A Java thread is always in one of the following ten states:

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.

The unused state (UNINITIALIZED) has been omitted from the list.

While the definitions of the states are given above I'm looking for "rule-of-thumbs" for interpreting a given thread state setup for a running appserver. And, more specifically:

Assume a live application server with the following thread statistics (obtained using jstack) at various points in time:

100 threads: 35 BLOCKED, 65 IN_NATIVE

113 threads: 35 BLOCKED, 77 IN_NATIVE, 1 IN_VM

52 threads: 38 BLOCKED, 1 IN_JAVA, 6 IN_NATIVE, 7 IN_VM

120 threads: 39 BLOCKED, 1 IN_JAVA, 80 IN_NATIVE

94 threads: 34 BLOCKED, 59 IN_NATIVE, 1 IN_NATIVE_TRANS

For each thread of the five statistics - what can be inferred with regards to the overall JVM state? I.e. "in this scenario the JVM looks to be idling waiting for requests", "the machine is busy processing requests", etc.

解决方案

This level of output doesn't provide enough information to make such statements.

As an example, consider the BLOCKED state: there are many things that can cause a thread to be blocked. Two of them are waiting for data to come from a client, and waiting for data to come back from a database. In the first case, your application is idle, in the second it's overloaded.

Edit: not having looked at the output from jstack, I suppose that these two conditions could also be represented as IN_NATIVE. However, the same comment holds: you don't know what they're doing, so you can't make any statements about the application as a whole.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值