View Thread Information
Tags: thread stack Information log tomcat response
Tomcat sometimes encounters situations in which all operations are slow to respond or have been unresponsive. If the error message is not visible through the log at this time. It may be difficult to analyze the source of the problem.
In this case, you can look at the thread information of Tomcat and see what is going on.
Reference URL https://www.cnblogs.com/shengulong/p/8513652.html
Jstack thread ID to see the stack of a thread, especially for hung dead threads, you can use option-F to force print dump information jstack-f PID
Jstack definition: Jstack is a stack trace tool that comes with Java virtual machines. The thread snapshot used to generate the current moment of the Java virtual machine. A thread snapshot is a collection of method stacks that each thread in the current Java Virtual machine is executing, and the primary purpose of generating a thread snapshot is to locate the cause of a thread's long pauses, such as inter-thread deadlocks, dead loops, long waits to request external resources, and so on.
PS: In the actual operation, often a dump of information, not enough to confirm the problem. It is recommended to generate three dump messages, and if each dump points to the same problem, we determine the typical problem. That is, take a few more threading snapshots, watch the changes, and see where the problem is.
Refer to the command jstack PID >run.log and then open the Run.log file with the attachment "View Thread Log" tool.
Main observations of several states
- Deadlock,Deadlock (focus on)
- In execution, Runnable
- Waiting for resources,waiting on condition (focus)
- Waiting to get the monitor,waiting on monitor entry (focus)
- Pause, Suspended
- Object waits, object.wait () or timed_waiting
- Blocking,Blocked (Focus)
- Stop, parked.
Then look at which code information each status is anchored to.
View Deadlock
View Monitors
Find the best code for threads
How many occurrences of search in the log file
Java View Tomcat thread information