/** * Dump all deadlocks (if any). * * @param msg the message * @param out the output */ public static void dumpAllThreadsAndLocks(String msg, PrintStream out) { final ThreadMXBean threadBean = ManagementFactory.getThreadMXBean(); final long[] allThreadIds = threadBean.getAllThreadIds(); dumpThreadsAndLocks(msg, threadBean, allThreadIds, out); }
/** * Checks if any threads are deadlocked. If any, print the thread dump * information. */ void checkForDeadlocks() { long[] deadlockedThreadIds = threadBean.findDeadlockedThreads(); if (deadlockedThreadIds == null) { return; } dumpThreadsAndLocks("ThreadDeadlockDetector - deadlock found :", threadBean, deadlockedThreadIds, System.out); }