用jstack0
命令dump
线程信息,查看pid
为31177
的进程里的线程状态
sudo -u admin /opt/ifeve/java/bin/jstack 31177 > /home/syske/dump17
统计所有线程分别处于什么状态
grep java.lang.Thread.State dump17 | awk '{pring $2$3$4$5}' | sort | uniq -c
关于线程的状态有一下几种:
- 死锁,
Deadlock
(重点关注) - 执行中,
Runnable
- 等待资源,
Waiting on condition
(重点关注) - 等待获取监视器,
Waiting on monitor entry
(重点关注) - 暂停,
Suspended
- 对象等待中,
Object.wait()
或TIMED_WAITING
- 阻塞,
Blocked
(重点关注) - 停止,
Parked
打开dump
文件查看处于WAITNG(ononjectmonitor)
的线程在做什么。
"Finalizer" #3 daemon prio=8 os_prio=1 tid=0x000001f196719000 nid=0x108 in Object.wait() [0x000000b1981fe000]
java.lang.Thread.State: WAITING (on object monitor)
at java.lang.Object.wait(Native Method)
- waiting on <0x00000000e24ef7b0> (a java.lang.ref.ReferenceQueue$Lock)
at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:144)
- locked <0x00000000e24ef7b0> (a java.lang.ref.ReferenceQueue$Lock)
at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:165)
at java.lang.ref.Finalizer$FinalizerThread.run(Finalizer.java:216)
根据统计及线程详情信息,调整线程池大小,优化WAITING(onobjectmonitor)
的线程数量