I have a threaddump and in this threaddump each thread is displayed in a format as below:
"isThreadCpuTimeSupported": "true",
"getLockOwnerName": null,
"isSuspended": "false",
"stacktrace": "java.base@11.0.5/java.net.PlainSocketImpl.accept0(Native
"cpuTime": "36359.375",
"userTime": "25828.125",
"threadState": "RUNNABLE",
"id": "1",
"lockName": null,
"threadName": "main",
"isNative": "true"
My requirement is to get the threadGroup of each thread, How can I get that? Do i have to add them in a thread group first? How do I know if they are already a part of threadgroup? On website Fastthread.io when I upload my thread dump it automatically finds the thread group, how does it do that?
On server side I am doing something like this to get threaddump:
ThreadMXBean tmbean = ManagementFactory.getThreadMXBean();
List<HashMap> list = new ArrayList<>();
long[] tids;
ThreadInfo[] tinfos;
tids = tmbean.getAllThreadIds();
tinfos = tmbean.getThreadInfo(tids, Integer.MAX_VALUE);
for (ThreadInfo ti : tinfos) {
try {
list.add( printThreadInfo(ti,tmbean,response ));
} catch (IOException ex) {
_logger.error("could not call printThreadInfo",ex);
}
}
...
...
and for each ti
map.put("threadName", ti.getThreadName());