I need to read the threads generated by other programs, which are running in the same JVM. I used the following code:
long a[] = ManagementFactory.getThreadMXBean().getAllThreadIds();
ThreadInfo[] thInfo = ManagementFactory.getThreadMXBean().getThreadInfo(a);
for(int i=0;i<thInfo.length;i++)
System.out.println(thInfo[i].getThreadName());
but without the expected success. Can you help me? Thanks