Java tutorial
//package com.java2s; //License from project: Apache License import java.lang.management.ManagementFactory; import java.lang.management.ThreadInfo; public class Main { public static String dumpAllThreads() { ThreadInfo[] dumps = ManagementFactory.getThreadMXBean().dumpAllThreads(true, true); StringBuilder out = new StringBuilder("Thread Dump\n"); for (ThreadInfo dump : dumps) { out.append("-------------------------\n").append(dump); } return out.toString(); } }