|
Groovy Documentation | |||||||
| FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||
java.lang.Objectjava.awt.EventQueue
org.jdesktop.swinghelper.debug.EventDispatchThreadHangMonitor
public final class EventDispatchThreadHangMonitor extends EventQueue
Monitors the AWT event dispatch thread for events that take longer than a certain time to be dispatched.
The principle is to record the time at which we start processing an event, and have another thread check frequently to see if we're still processing. If the other thread notices that we've been processing a single event for too long, it prints a stack trace showing what the event dispatch thread is doing, and continues to time it until it finally finishes. This is useful in determining what code is causing your Java application's GUI to be unresponsive.The original blog can be found here
Automatically detecting AWT event dispatch thread hangs
| Nested Class Summary | |
|---|---|
private static class |
EventDispatchThreadHangMonitor.DispatchInfo
|
private class |
EventDispatchThreadHangMonitor.HangChecker
|
| Field Summary | |
|---|---|
private static long |
CHECK_INTERVAL_MS
|
private static EventDispatchThreadHangMonitor |
INSTANCE
|
private static org.slf4j.Logger |
LOG
|
private static long |
UNREASONABLE_DISPATCH_DURATION_MS
|
private LinkedList |
dispatches
|
private static int |
hangCount
|
private boolean |
haveShownSomeComponent
|
private long |
timeout
|
| Constructor Summary | |
EventDispatchThreadHangMonitor()
|
|
| Method Summary | |
|---|---|
private def
|
EventDispatchThreadHangMonitor()
|
private static void
|
checkForDeadlock()
|
protected void
|
dispatchEvent(AWTEvent event)
|
static EventDispatchThreadHangMonitor
|
getInstance()
|
private static int
|
getNewHangNumber()
|
long
|
getTimeout()
|
static void
|
initMonitoring()
Overrides EventQueue.dispatchEvent to call our pre and post hooks either side of the system's event dispatch code. |
private void
|
initTimer()
Sets up hang detection for the event dispatch thread. |
private void
|
postDispatchEvent()
|
private void
|
preDispatchEvent()
|
void
|
setTimeout(long timeout)
Stops tracking a dispatch. |
private static String
|
stackTraceToString(StackTraceElement[] stackTrace)
|
| Methods inherited from class EventQueue | |
|---|---|
| push, postEvent, isDispatchThread, invokeLater, getMostRecentEventTime, getCurrentEvent, invokeAndWait, getNextEvent, peekEvent, peekEvent, wait, wait, wait, equals, toString, hashCode, getClass, notify, notifyAll |
| Methods inherited from class Object | |
|---|---|
| wait, wait, wait, equals, toString, hashCode, getClass, notify, notifyAll |
| Field Detail |
|---|
private static final long CHECK_INTERVAL_MS
private static final EventDispatchThreadHangMonitor INSTANCE
private static final org.slf4j.Logger LOG
private static final long UNREASONABLE_DISPATCH_DURATION_MS
private final LinkedList dispatches
private static int hangCount
private boolean haveShownSomeComponent
private long timeout
| Constructor Detail |
|---|
EventDispatchThreadHangMonitor()
| Method Detail |
|---|
private def EventDispatchThreadHangMonitor()
private static void checkForDeadlock()
@Overridefor (DispatchInfo dispatchInfo : dispatches) {
protected void dispatchEvent(AWTEvent event)
public static EventDispatchThreadHangMonitor getInstance()
private static int getNewHangNumber()
public long getTimeout()
public static void initMonitoring()
private void initTimer()
private void postDispatchEvent()
private void preDispatchEvent()
public void setTimeout(long timeout)
private static String stackTraceToString(StackTraceElement[] stackTrace)
Groovy Documentation