cause of the problem: because the HashMap is non-thread-safe, it causes a dead loop during multithreaded access.
To find the problem method:
1.
Java code
- Top
Find the CPU-intensive process number such as: 27377
2.
Java code
- Top-p 27377-h
Find out all the threads under this process, and then find the CPU thread number that consumes the most: 27433
3.
Java code
- Python hex (27433)
Converts a decimal number to a 16 binary such as: 0x6b29
4.
Java code
- Jstack 27377 >cpu.log
Print the Java stack information for this process number to a file
5.
Java code
- grep 0x6bz8 Cpu.log
Look at the threads in the Java stack, nid:
"FoundationTaskExecutor-2" prio=10 tid=0x00007f064c041000 nid=0x6b28 runnable [0x00007f069f5da000]
6.
Java code
- Vim Cpu.log
Find the contents of nid=0x6b28 such as:
Java code
- "FoundationTaskExecutor-2" prio=tid=0x00007f064c041000 nid= 0x6b28runnable [0x00007f069f5da000]
- Java.lang.Thread.State:RUNNABLE
- At Java.util.HashMap.get (Hashmap.java:)
- At *********************************** (Wareserviceimpl.java: +)
- At *********************************** (Mid2foundationtask.java:127)
- At *********************************** (Mid2foundationtask.java:)
- At *********************************** $FoundationThreadImpl. Run (Mid2foundationtask.java:
- At Java.util.concurrent.ThreadPoolExecutor.runWorker (Threadpoolexecutor.java:1110)
- At Java.util.concurrent.threadpoolexecutor$worker.run (Threadpoolexecutor.java:603)
- At Java.lang.Thread.run (Thread.java:722)
Java program consumes CPU 100% lookup method