The article directories

1. Query which process occupies the CPU

Which thread of the process occupies the CPU

3. Query thread stack information

preface

CPU surge high, basic is three plate axe can find specific OCCUPY CPU thread information, so, you see the CPU is so high, is what thread in trouble!

1. Query which process occupies the CPU

You can use the Top or Top | grep user name

As here we can use the top | grep deploy query for the current user deploy what process more CPU below, the following figure, can find 28284 more CPU process

Which thread of the process occupies the CPU

Then we can see which threads in the above process are causing trouble, using the command top-h -p PID

Here we use top-H-P 28284, and the result is shown in the following figure. We find that several threads occupy relatively high occupancy, such as 28389, 28390, etc. (Here we only show the effect, do not care whether the occupation is really large)

3. Query thread stack information

We’re going to do this in two steps

1. Convert tid to a hexadecimal number: printf “%x\n” tid

2, query thread information: jstack 28284 | grep ee5 6-10 A

Execution result as the chart, we can see the specific is in our application which thread CPU is higher, for instance, there is a call SimplePauseDetectorThread_1 threads, thread according to the specific business analysis is below