现在我们来找到这个进程中占用 CPU 较高的那些线程: $ ps p 10495 -L -o pcpu,pid,tid,time,tname,cmd > ~/10495ps.txt 多次拉这个快照,我们找到了 tid 为 10499、10500、10501、10502 等线程占用 CPU 很高:
拉 JStack 快照看看都是一些什么线程: $ /opt/jdk1.6.0_45/bin/jstack -l 10495 > ~/10495jstack.txt 相关部分结果如下: "(GC Worker Thread 1)" id=? idx=0x10 tid=10499 prio=5 alive, daemon at pthread_cond_wait@@GLIBC_2.3.2+202(:0)@0x3708c0b44a at eventTimedWaitNoTransitionImpl+71(event.c:90)@0x7fac47be8528 at eventTimedWaitNoTransition+66(event.c:72)@0x7fac47be8593 at mmGCWorkerThread+137(gcthreads.c:809)@0x7fac47c0774a at thread_stub+170(lifecycle.c:808)@0x7fac47cc15bb at start_thread+208(:0)@0x3708c077e1 Locked ownable synchronizers: - None
"(GC Worker Thread 2)" id=? idx=0x14 tid=10500 prio=5 alive, daemon at pthread_cond_wait@@GLIBC_2.3.2+202(:0)@0x3708c0b44a at eventTimedWaitNoTransitionImpl+71(event.c:90)@0x7fac47be8528 at eventTimedWaitNoTransition+66(event.c:72)@0x7fac47be8593 at mmGCWorkerThread+137(gcthreads.c:809)@0x7fac47c0774a at thread_stub+170(lifecycle.c:808)@0x7fac47cc15bb at start_thread+208(:0)@0x3708c077e1 Locked ownable synchronizers: - None
"(GC Worker Thread 3)" id=? idx=0x18 tid=10501 prio=5 alive, daemon at pthread_cond_wait@@GLIBC_2.3.2+202(:0)@0x3708c0b44a at eventTimedWaitNoTransitionImpl+71(event.c:90)@0x7fac47be8528 at eventTimedWaitNoTransition+66(event.c:72)@0x7fac47be8593 at mmGCWorkerThread+137(gcthreads.c:809)@0x7fac47c0774a at thread_stub+170(lifecycle.c:808)@0x7fac47cc15bb at start_thread+208(:0)@0x3708c077e1 Locked ownable synchronizers: - None
"(GC Worker Thread 4)" id=? idx=0x1c tid=10502 prio=5 alive, daemon at pthread_cond_wait@@GLIBC_2.3.2+202(:0)@0x3708c0b44a at eventTimedWaitNoTransitionImpl+71(event.c:90)@0x7fac47be8528 at eventTimedWaitNoTransition+66(event.c:72)@0x7fac47be8593 at mmGCWorkerThread+137(gcthreads.c:809)@0x7fac47c0774a at thread_stub+170(lifecycle.c:808)@0x7fac47cc15bb at start_thread+208(:0)@0x3708c077e1 Locked ownable synchronizers: - None