43
44 /**
45 * Constructor of HotspotThread class.
46 */
47 HotspotThread(VMManagement vm) {
48 jvm = vm;
49 }
50
51 public native int getInternalThreadCount();
52
53 public Map<String, Long> getInternalThreadCpuTimes() {
54 int count = getInternalThreadCount();
55 if (count == 0) {
56 return java.util.Collections.emptyMap();
57 }
58 String[] names = new String[count];
59 long[] times = new long[count];
60 int numThreads = getInternalThreadTimes0(names, times);
61 Map<String, Long> result = new HashMap<>(numThreads);
62 for (int i = 0; i < numThreads; i++) {
63 result.put(names[i], new Long(times[i]));
64 }
65 return result;
66 }
67 public native int getInternalThreadTimes0(String[] names, long[] times);
68
69 // Performance counter support
70 private static final String JAVA_THREADS = "java.threads.";
71 private static final String COM_SUN_THREADS = "com.sun.threads.";
72 private static final String SUN_THREADS = "sun.threads.";
73 private static final String THREADS_COUNTER_NAME_PATTERN =
74 JAVA_THREADS + "|" + COM_SUN_THREADS + "|" + SUN_THREADS;
75
76 public java.util.List<Counter> getInternalThreadingCounters() {
77 return jvm.getInternalCounters(THREADS_COUNTER_NAME_PATTERN);
78 }
79 }
|
43
44 /**
45 * Constructor of HotspotThread class.
46 */
47 HotspotThread(VMManagement vm) {
48 jvm = vm;
49 }
50
51 public native int getInternalThreadCount();
52
53 public Map<String, Long> getInternalThreadCpuTimes() {
54 int count = getInternalThreadCount();
55 if (count == 0) {
56 return java.util.Collections.emptyMap();
57 }
58 String[] names = new String[count];
59 long[] times = new long[count];
60 int numThreads = getInternalThreadTimes0(names, times);
61 Map<String, Long> result = new HashMap<>(numThreads);
62 for (int i = 0; i < numThreads; i++) {
63 result.put(names[i], times[i]);
64 }
65 return result;
66 }
67 public native int getInternalThreadTimes0(String[] names, long[] times);
68
69 // Performance counter support
70 private static final String JAVA_THREADS = "java.threads.";
71 private static final String COM_SUN_THREADS = "com.sun.threads.";
72 private static final String SUN_THREADS = "sun.threads.";
73 private static final String THREADS_COUNTER_NAME_PATTERN =
74 JAVA_THREADS + "|" + COM_SUN_THREADS + "|" + SUN_THREADS;
75
76 public java.util.List<Counter> getInternalThreadingCounters() {
77 return jvm.getInternalCounters(THREADS_COUNTER_NAME_PATTERN);
78 }
79 }
|