Java tutorial
//package com.java2s; //License from project: Apache License import java.lang.management.ManagementFactory; import java.lang.management.ThreadMXBean; public class Main { public static String getDeadlockedThreads() { ThreadMXBean bean = ManagementFactory.getThreadMXBean(); long[] deadlocked = bean.findMonitorDeadlockedThreads(); if (deadlocked == null || deadlocked.length == 0) { return ""; } String buf = "Deadlocked thread IDs: "; for (long id : deadlocked) { buf += id + " "; } return buf; } }