SUGGESTED FIX
Subclass the java.lang.management.ThreadMXBean interface, call it
com.sun.management.ThreadMXBean. Instead of having
sun.management.ThreadImpl implement j.l.m.ThreadMXBean, have it
implement c.s.m.ThreadMXBean.
By analogy to the existing getThreadCpuTime methods, add to
c.s.m.ThreadMXBean the following methods.
void long getCurrentThreadAllocatedBytes(long id);
void long getThreadAllocatedBytes(long id);
boolean isThreadAllocatedBytesSupported();
boolean isCurrentThreadAllocatedBytesSupported();
boolean isThreadAllocatedBytesEnabled();
void setThreadAllocatedBytesEnabled(boolean enable);
In addition, add methods to c.s.m.ThreadMXBean to get info for
multiple threads at once.
void long[] getThreadCpuTime(long [] ids);
void long[] getThreadUserTime(long [] ids);
void long[] getTheadAllocatedBytes(long [] ids);
The get*AllocatedBytes methods return an approximation to the number
of bytes allocated by a thread or threads on the Java heap from the
time it or they start executing up to the time of the call.
|