package org.nhooo.example.management; import java.lang.management.ManagementFactory; import java.lang.management.ThreadMXBean; public class PeakThreadCount { public static void main(String[] args) { // 获取Java线程系统的托管bean // 虚拟机。 ThreadMXBean bean = ManagementFactory.getThreadMXBean(); // 自Java虚拟以来获取活动线程峰值 // 机器启动或重置峰值。 int peakThreadCount = bean.getPeakThreadCount(); System.out.println("Peak Thread Count = " + peakThreadCount); } }