A project CPU occupation rate has been very high, often between 40%-50%, recently relatively busy, began to hang the work.
1. Output the stack information of the process via the Jstack command
Jstack 2788 >c:\log.txt
Output stack information to Log.txt
"Dubbo-remoting-client-heartbeat-thread-1" #46 daemon prio=5 os_prio=0 tid=0x000000005c53e000 nid=0x240c waiting on condition [0x000000006447f000] Java.lang.Thread.State:WAITING (parking) at Sun.misc.Unsafe.park (Native Method)-Parking to wait for<0x00000000e17fc110>(a java.util.concurrent.locks.abstractqueuedsynchronizer$conditionobject) at Java.util.concurrent.locks.LockSupport.park (Locksupport.java:175) at Java.util.concurrent.locks.abstractqueuedsynchronizer$conditionobject.await ( Abstractqueuedsynchronizer.java:2039) at Java.util.concurrent.scheduledthreadpoolexecutor$delayedworkqueue.take (Scheduledthreadpoolexecutor.java :1088) at Java.util.concurrent.scheduledthreadpoolexecutor$delayedworkqueue.take (Scheduledthreadpoolexecutor.java :809) at Java.util.concurrent.ThreadPoolExecutor.getTask (Threadpoolexecutor.java:1067) at Java.util.concurrent.ThreadPoolExecutor.runWorker (Threadpoolexecutor.java:1127) at Java.util.concurrent.threadpoolexecutor$worker.run (Threadpoolexecutor.java:617) at Java.lang.Thread.run (Thread.java:745) Locked ownable synchronizers:-None"Hashed Wheel timer #1" #41 prio=5 os_prio=0 tid=0x000000005c53c800 nid=0x271c runnable [0x0000000063fae000] Java.lang.Thread.State:RUNNABLE at Java.lang.Thread.sleep (Native Method) at Org.jboss.netty.util.HashedWhee Ltimer$worker.waitfornexttick (Hashedwheeltimer.java:504) at Org.jboss.netty.util.hashedwheeltimer$worker.run (Hashedwheeltimer.java:402) at Org.jboss.netty.util.ThreadRenamingRunnable.run (Threadrenamingrunnable.java:108) at Java.lang.Thread.run (Thread.java:745) Locked ownable synchronizers:-None"Dubboclientreconnecttimer-thread-1" #44 daemon prio=5 os_prio=0 tid=0x0000000059883800 nid=0x2700 waiting on condition [0x000000006362f000] Java.lang.Thread.State:TIMED_WAITING (parking) at Sun.misc.Unsafe.park (Native Method)-Parking to wait for<0x00000000e1825be0>(a java.util.concurrent.locks.abstractqueuedsynchronizer$conditionobject) at Java.util.concurrent.locks.LockSupport.parkNanos (Locksupport.java:215) at Java.util.concurrent.locks.abstractqueuedsynchronizer$conditionobject.awaitnanos ( Abstractqueuedsynchronizer.java:2078) at Java.util.concurrent.scheduledthreadpoolexecutor$delayedworkqueue.take (Scheduledthreadpoolexecutor.java :1093) at Java.util.concurrent.scheduledthreadpoolexecutor$delayedworkqueue.take (Scheduledthreadpoolexecutor.java :809) at Java.util.concurrent.ThreadPoolExecutor.getTask (Threadpoolexecutor.java:1067) at Java.util.concurrent.ThreadPoolExecutor.runWorker (Threadpoolexecutor.java:1127) at Java.util.concurrent.threadpoolexecutor$worker.run (Threadpoolexecutor.java:617) at Java.lang.Thread.run (Thread.java:745)
2. Find threads with high CPU usage through Processexplorer
As you can see, the thread ID that consumes the CPU too high is 8924, then 8924 is converted to 16, and the corresponding stack information is queried in the log.txt just output.
then query the corresponding code. High CPU is generally a column cycle.
Troubleshooting a Java CPU at a time of high consumption