0

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

JoeJoe
  • 83
  • 1
  • 12
  • see this http://stackoverflow.com/questions/1323408/get-a-list-of-all-threads-currently-running-in-java – Aris2World Aug 03 '16 at 10:31
  • 1
    Please define "expected success" and "other programs". Note that if you start a new java application you'll start a new and independent JVM instance which you can't get the threads of. – Thomas Aug 03 '16 at 10:31
  • "Other programs running in the same JVM"? Normally you have one JVM instance per program (unless you're talking about web applications running in a servlet container, for example). – Jesper Aug 03 '16 at 10:32
  • I wanted to know how to get all the names and status of the threads that are running on my server. Thank you – JoeJoe Aug 03 '16 at 10:39

0 Answers0