Top Description Fields Constructors Methods
org.h2.util

public Class ThreadDeadlockDetector

extends Object
Class Inheritance
Imports
java.io.PrintStream, .PrintWriter, .StringWriter, java.lang.management.LockInfo, .ManagementFactory, .MonitorInfo, .ThreadInfo, .ThreadMXBean, java.util.ArrayList, .HashMap, .Timer, .TimerTask, org.h2.engine.SysProperties, org.h2.mvstore.db.MVTable

Detects deadlocks between threads. Prints out data in the same format as the CTRL-BREAK handler, but includes information about table locks.

Field Summary

Modifier and TypeField and Description
private static ThreadDeadlockDetector
private static final String
private final ThreadMXBean

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
pack-priv void
checkForDeadlocks()

Checks if any threads are deadlocked.

public static void
dumpAllThreadsAndLocks(String
the message
msg
)

Dump all deadlocks (if any).

public static void
dumpAllThreadsAndLocks(String
the message
msg
,
PrintStream
the output
out
)

Dump all deadlocks (if any).

private static void
dumpThreadsAndLocks(String msg, ThreadMXBean threadBean, long[] threadIds, PrintStream out)

public static synchronized void
init()

Initialize the detector.

private static void
printLockInfo(PrintWriter print, LockInfo[] locks, String tableWaitingForLock, ArrayList<String> tableExclusiveLocks, ArrayList<String> tableSharedLocksMap)

private static void
private static void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

detectorback to summary
private static ThreadDeadlockDetector detector
INDENTback to summary
private static final String INDENT
threadBeanback to summary
private final ThreadMXBean threadBean

Constructor Detail

ThreadDeadlockDetectorback to summary
private ThreadDeadlockDetector()

Method Detail

checkForDeadlocksback to summary
pack-priv void checkForDeadlocks()

Checks if any threads are deadlocked. If any, print the thread dump information.

dumpAllThreadsAndLocksback to summary
public static void dumpAllThreadsAndLocks(String msg)

Dump all deadlocks (if any).

Parameters
msg:String

the message

dumpAllThreadsAndLocksback to summary
public static void dumpAllThreadsAndLocks(String msg, PrintStream out)

Dump all deadlocks (if any).

Parameters
msg:String

the message

out:PrintStream

the output

dumpThreadsAndLocksback to summary
private static void dumpThreadsAndLocks(String msg, ThreadMXBean threadBean, long[] threadIds, PrintStream out)
initback to summary
public static synchronized void init()

Initialize the detector.

printLockInfoback to summary
private static void printLockInfo(PrintWriter print, LockInfo[] locks, String tableWaitingForLock, ArrayList<String> tableExclusiveLocks, ArrayList<String> tableSharedLocksMap)
printThreadback to summary
private static void printThread(PrintWriter print, ThreadInfo ti)
printThreadInfoback to summary
private static void printThreadInfo(PrintWriter print, ThreadInfo ti)