Tools for monitoring java thread execution
I have a Java Web application running on a Tomcat server (Linux) In the production environment, I encountered some performance problems The JSVC process running Tomcat at random intervals starts to run with 90-100% CPU I can't find a trigger for this event The server is a quad core system Memory consumption does not indicate any exceptions
How do I monitor which thread (application stack trace) in the application is causing the problem?
I'm checking jconsole and PSI probe, but neither provides any details about CPU usage exceptions caused by internal threads in the application
Solution
A relatively simple approach (which may or may not work for your situation) depends on the length of time the behavior occurs:
When your application shows the behavior you want to debug (in this case, the CPU utilization is 90-100%), use jstack on the process ID:
http://download.oracle.com/javase/6/docs/technotes/tools/share/jstack.html
Check running threads and how they occur If you do this several times, it may be relatively easy to find the culprit's call chain You can then debug the entry of the chain
It's not necessarily the best or most elegant method, but it's easy to do. It may be what you need I'll start there It's similar to the "printf is the best debugger I've ever used" philosophy