java 进程 线程_JAVA进程中的线程分析

kill -3 java_pid命令将输出java进程的线程信息。

在AIX上在域的目录下生成javacore文件

在linux上,信息将输出到console

对于thread dump信息,主要关注的是线程的状态和其执行堆栈

线程的状态一般为三类

Runnable(R):当前可以运行的线程

Waiting on monitor(CW):线程主动wait

Waiting for monitor entry(MW):线程等锁

一般关注的都是第一和第三种状态的线程

Cpu很忙则关注runnable的线程

Cpu闲则关注waiting for monitor entry的线程

状态参考:

R - Running or runnable thread

S - Suspended thread

CW- Thread waiting on a condition variable(it is in a Thread.sleep or in a synchronized wait.)

MW - Thread waiting on a monitor lock(等待一个线程锁)

MS - Thread suspended waiting on a monitor lock(there is a good chance it is a bug. )

Monitors are used to manage access to code that should only be run by a single thread at a time. A monitor can be thought of as a lock on an object, and every object has a monitor. (Monitor其实就是对象上面的锁,提供多线程使用一个对象的机制)

Monitor类型:

utf8 hash table -Locks the hashtable of defined i18N Strings that were loaded from the class constant pool.

JNI pinning lock- Protects block copies of arrays to native method code.

JNI global reference lock -Locks the global reference table which holds values that need to be explicitly freed, and will outlive the lifetime of the native method call.

BinClass lock- Locks access to the loaded and resolved classes list. The global table list of classes

Class linking lock- Protects a classes data when loading native libraries to resolve symbolic references

System class loader lock- Ensures that only one thread is loading a system class at a time.

Code rewrite lock -Protects code when an optimization is attempted.

Heap lock- Protects the Java heap during heap memory management

Monitor cache lock -Only one thread can have access to the monitor cache at a time this lock ensures the integrity of the monitor cache

Dynamic loading lock- Protects Unix green threads JVMs from loading the shared library stub libdl.so more than once at a time.

Monitor IO lock -Protects physical I/O for example, open and read.

User signal monitor- Controls access to the signal handler if a user signal USRSIG in green threads JVMs.

Child death monitor -Controls access to the process wait information when using the runtime system calls to run locals commands in a green threads JVM.

I/O Monitor -Controls access to the threads file descriptors for poll/select events

Alarm Monitor- Controls access to a clock handler used in green threads JVMs to handle timeouts

Thread queue lock -Protects the queue of active threads

Monitor registry -Only one thread can have access to the monitor registry at a time this lock ensures the integrity of that registry

Has finalization queue lock *- Protects the list of queue lock objects that have been garbage-collected, and deemed to need finalization. They are copied to the Finalize me queue

Finalize me queue lock * -Protects a list of objects that can be finalized at leisure

Name and type hash table lock * -Protects the JVM hash tables of constants and their types

String intern lock * -Locks the hashtable of defined Strings that were loaded from the class constant pool

Class loading lock * -Ensures only one thread loads a class at a time

Java stack lock * -Protects the free stack segments list

linux上查看线程

用于 Linux 的 JVM 将 Java 线程作为本地线程实现,这使每个线程成为一个独立的 Linux 进程。

使用top找出消耗cpu最多的进程ID,把它转换为16进制数据,再threaddump文件中找nid=0X2234E的线程,看它再做什么事情。

AIX上查看java进程下所有线程的信息:

输出线程ID

ps -mp 241888 -o THREAD

USER PID PPID TID ST CP PRI SC WCHAN F TT BND COMMAND

weblogic 241888 372868 - A 0 68 76 * 242001 - - /usr/java14/bin/java -Xms1024m -Xmx1024m -Dweblogic.Na

- - - 663693 Z 0 68 1 - c00001 - - -

- - - 671855 S 0 68 1 f100070f1000a440 8410400 - - -

- - - 753805 S 0 68 1 f100070f1000b840 8410400 - - -

- - - 766023 S 0 68 1 f10001001fe6aeb0 410400 - - -

- - - 774329 S 0 68 1 f100070f1000bd40 8410400 - - -

- - - 790667 S 0 68 1 f100070f1000c140 8410400 - - -

- - - 794635 S 0 68 1 f100070f1000c240 8410400 - - -

- - - 798813 S 0 68 1 f100070f1000c340 8410400 - - -

- - - 803021 Z 0 68 1 - c00001 - - -

- - - 807051 S 0 68 1 f100070f1000c540 8410400 - - -

- - - 811149 S 0 68 1 f100070f1000c640 8410400 - - -

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值