Can you pause a Java application and get a snapshot of its threads from the application?

I look at the monitoring code that runs inside a Java application, and periodically takes a snapshot of the threads starting and displays information about each call stack on each of them.

Ideally, this will be expanded for profiling and / or monitoring.

I do not want to use an external tool, as this is for self-education.

+3
source share
5 answers
+4
source

Take a look at ThreadMXBean.dumpAllThreads(boolean, boolean)

ThreadMXBean bean = ManagementFactory.getThreadMXBean();
ThreadInfo[] info = bean.dumpAllThreads(true, true);
+3
source

Thread, Thread.enumerate(), Thread.activeCount(), Thread.getName()?

+1

You can register the streams that you want to watch at the time of creation, and have a separate stream of indicators for monitoring. You would like to create specific metrics in the stream, for example, a list of recent launches, current throughput, or other types of metrics.

+1
source

kill -SIGQUIT {java_process}

will delete all stack traces in the stdout of the java process.

0
source

Source: https://habr.com/ru/post/1748568/


All Articles