Java Code Examples for com.sun.management.ThreadMXBean#getAllThreadIds()

The following examples show how to use com.sun.management.ThreadMXBean#getAllThreadIds() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AllThreadInfoQuestion.java    From tech-weekly with Apache License 2.0 5 votes vote down vote up
public static void main(String[] args) {
        ThreadMXBean threadMXBean = (ThreadMXBean) ManagementFactory.getThreadMXBean();
        long[] threadIds = threadMXBean.getAllThreadIds();

        for (long threadId : threadIds) {
//            ThreadInfo threadInfo = threadMXBean.getThreadInfo(threadId);
//            System.out.println(threadInfo.toString());
            long bytes = threadMXBean.getThreadAllocatedBytes(threadId);
            long kBytes = bytes / 1024;
            System.out.printf("线程[ID:%d] 分配内存: %s KB\n", threadId, kBytes);
        }

    }
 
Example 2
Source File: SurvivorAlignmentTestMain.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Baselines amount of memory allocated by each thread.
 */
public void baselineMemoryAllocation() {
    ThreadMXBean bean = (ThreadMXBean) ManagementFactory.getThreadMXBean();
    threadIds = bean.getAllThreadIds();
    baselinedThreadMemoryUsage = bean.getThreadAllocatedBytes(threadIds);
}
 
Example 3
Source File: SurvivorAlignmentTestMain.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Baselines amount of memory allocated by each thread.
 */
public void baselineMemoryAllocation() {
    ThreadMXBean bean = (ThreadMXBean) ManagementFactory.getThreadMXBean();
    threadIds = bean.getAllThreadIds();
    baselinedThreadMemoryUsage = bean.getThreadAllocatedBytes(threadIds);
}
 
Example 4
Source File: SurvivorAlignmentTestMain.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Baselines amount of memory allocated by each thread.
 */
public void baselineMemoryAllocation() {
    ThreadMXBean bean = (ThreadMXBean) ManagementFactory.getThreadMXBean();
    threadIds = bean.getAllThreadIds();
    baselinedThreadMemoryUsage = bean.getThreadAllocatedBytes(threadIds);
}
 
Example 5
Source File: SurvivorAlignmentTestMain.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Baselines amount of memory allocated by each thread.
 */
public void baselineMemoryAllocation() {
    ThreadMXBean bean = (ThreadMXBean) ManagementFactory.getThreadMXBean();
    threadIds = bean.getAllThreadIds();
    baselinedThreadMemoryUsage = bean.getThreadAllocatedBytes(threadIds);
}
 
Example 6
Source File: SurvivorAlignmentTestMain.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Baselines amount of memory allocated by each thread.
 */
public void baselineMemoryAllocation() {
    ThreadMXBean bean = (ThreadMXBean) ManagementFactory.getThreadMXBean();
    threadIds = bean.getAllThreadIds();
    baselinedThreadMemoryUsage = bean.getThreadAllocatedBytes(threadIds);
}
 
Example 7
Source File: SurvivorAlignmentTestMain.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Baselines amount of memory allocated by each thread.
 */
public void baselineMemoryAllocation() {
    ThreadMXBean bean = (ThreadMXBean) ManagementFactory.getThreadMXBean();
    threadIds = bean.getAllThreadIds();
    baselinedThreadMemoryUsage = bean.getThreadAllocatedBytes(threadIds);
}