Java线程:解释正在运行的JVM的线程状态 [英] Java threads: interpreting thread states of a running JVM

查看:1766
本文介绍了Java线程:解释正在运行的JVM的线程状态的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Java线程始终处于以下十种状态之一:

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.

未使用状态( UNINITIALIZED )已经过从列表中省略。

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

虽然上面给出了状态的定义,但我正在寻找用于解释给定线程状态设置的经验法则运行appserver。更具体地说:

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:

假设一个具有以下线程统计信息的实时应用程序服务器(使用 jstack )在不同的时间点:

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


  • 100个主题:35 BLOCKED ,65 IN_NATIVE

  • 113个主题:35 BLOCKED ,77 IN_NATIVE ,1 IN_VM

  • 52个主题:38 BLOCKED ,1 IN_JAVA ,6 IN_NATIVE ,7 IN_VM

  • 120个主题:39 BLOCKED ,1 IN_JAVA ,80 IN_NATIVE

  • 94主题:34 BLOCKED ,59 IN_NATIVE ,1 IN_NATIVE_TRANS

  • 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

对于五个统计信息中的每个线程 - 关于整体JVM状态可以推断什么?即在这种情况下,JVM看起来正在等待请求,机器正忙于处理请求等等。

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.

作为一个例子,考虑BLOCKED状态:有很多东西可以导致一个线程被封锁其中两个正在等待来自客户端的数据,并等待数据从数据库返回。在第一种情况下,你的应用程序是空闲的,在第二种情况下它是超载的。

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.

编辑:没有看过jstack的输出,我想这两个条件也可以表示为IN_NATIVE。但是,同样的评论认为:你不知道他们在做什么,所以你不能对整个申请做任何陈述。

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.

这篇关于Java线程:解释正在运行的JVM的线程状态的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆