spring boot racing simulation high code
public class TestWhile
{
/ * operation memory object * /
of ConcurrentHashMap Map of ConcurrentHashMap new new = ();
Private void whileTrue (String threadName) {
// exit condition is not set, the cycle of death
the while (to true) {
// continuously in an endless loop map for the put operation, resulting in memory GC
for (int I = 0; I <= 100000; I ++) {
map.put (. Thread.currentThread () getName () + I, I);
} // End for
} End the while //
}
@PostConstruct
public void testWhile () {
// loop size, creating a multi-threaded, concurrent execution of an endless loop
for (int I = 0; I <20 is; I ++) {
int Finali = I;
// and start a new thread calls the method whileTrue
new new the Thread (() -> {
whileTrue ( "Li -" + Finali);
.}) Start ();
}
}
}
top
Taobao use open source show-busy-java-threads rapid investigation
- Introduction:
- Author: Taobao RiKanae (AkiraRyo) oldratlee
- For fast troubleshooting Java CPU performance issues (top us too high), CPU automatically detect many threads running Java process consumes, and print out their thread stack to determine the cause of performance problems method call.
- Git Address: https://github.com/oldratlee/useful-scripts
Execution: curl -sLk ' https://raw.github.com/oldratlee/useful-scripts/release-2.x/bin/show-busy-java-threads ' | -s bash - -a 2.log
2.log output to a file.
Results: GC-induced CPU racing, [5] due to the thread executing code GC method. WhileTrue method can locate a problem.
Taobao use open source Arthas troubleshooting
- Description: Arthas is Alibaba open source Java diagnostic tools, the industry's strongest.
- GIT Address: https://github.com/alibaba/arthas/blob/master/README_CN.md
- Not only is the CPU thread troubleshooting almost all issues, including the investigation of online decompile, dynamic hot update operation code online request link tracking and more.
-The curl https://alibaba.github.io/arthas/arthas-boot.jar
java -jar arthas-boot.jar
Select the process of investigation required
1 + Enter
Dashboard command execution
CPU can determine the initial height of GC-induced Biao
Execution thread -n 3 -i 5000 View CPU usage Top N thread's stack
Results: GC-induced high CPU Biao, you can locate a link to the thread run method whileTrue problem.
Problem recommended in the service, perform the following curl -sLk c ' https://raw.github.com/oldratlee/useful-scripts/release-2.x/bin/show-busy-java-threads ' | -s bash - - -a 2.log then restart, there will be a problem to write this record after restart