1

Suppose I want to capture the threads dump by Jmap or alternative ways automatically when the number of tomcat threads over 500,how to achieve it?

BTW, the environment is Linux CentOS.

YuFeng Shen
  • 1,475
  • 1
  • 17
  • 41
  • What is the problem? Monitor the number of Tomcat threads through JMX and whenever it reaches a threshold, execute jstack. – apangin Jul 04 '17 at 17:31
  • We have a tomcat Application, and it's threads number often increased to a large number at randomly time in short time, it would last some minutes(meaning we often no time to capture the thread dump manually), then dropped .I want to see what's happens for these threads. so you mean I need to write a JMX program, and invokes the jstack from the JMX program when issue happens? – YuFeng Shen Jul 05 '17 at 01:58
  • As I have no idea how to run tool jstack from the JMX program. Running the shell script ,which invokes the Jstack , from the Java code? – YuFeng Shen Jul 05 '17 at 02:08
  • Yes; why not. There are [other ways](https://stackoverflow.com/questions/26795573/which-method-is-the-least-obtrusive-for-generating-thread-dumps-in-java/26810701#26810701) to make a thread dump, but `Runtime.exec` is just easier. – apangin Jul 05 '17 at 04:48

0 Answers0