Package edu.wisc.ssec.mcidasv.util.gui
Class EventDispatchThreadHangMonitor
java.lang.Object
java.awt.EventQueue
edu.wisc.ssec.mcidasv.util.gui.EventDispatchThreadHangMonitor
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
- Author:
- Elliott Hughes invalid input: '<'enh@jessies.org> Advice, bug fixes, and test cases from Alexander Potochkin and Oleg Sukhodolsky. https://swinghelper.dev.java.net/
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static class
private class
private static class
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final long
private final LinkedList
<EventDispatchThreadHangMonitor.DispatchInfo> private static int
private boolean
private static final EventDispatchThreadHangMonitor
private static final org.slf4j.Logger
private static final long
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static void
protected void
dispatchEvent
(AWTEvent event) Overrides EventQueue.dispatchEvent to call our pre and post hooks either side of the system's event dispatch code.private static int
static void
Sets up hang detection for the event dispatch thread.private void
Sets up a timer to check for hangs frequently.static void
private void
Stops tracking a dispatch.private void
Starts tracking a dispatch.private static String
stackTraceToString
(StackTraceElement[] stackTrace) Methods inherited from class java.awt.EventQueue
createSecondaryLoop, getCurrentEvent, getMostRecentEventTime, getNextEvent, invokeAndWait, invokeLater, isDispatchThread, peekEvent, peekEvent, pop, postEvent, push
-
Field Details
-
logger
-
INSTANCE
-
CHECK_INTERVAL_MS
- See Also:
-
UNREASONABLE_DISPATCH_DURATION_MS
- See Also:
-
hangCount
-
haveShownSomeComponent
-
dispatches
-
-
Constructor Details
-
EventDispatchThreadHangMonitor
private EventDispatchThreadHangMonitor()
-
-
Method Details
-
initTimer
Sets up a timer to check for hangs frequently. -
initMonitoring
Sets up hang detection for the event dispatch thread. -
dispatchEvent
Overrides EventQueue.dispatchEvent to call our pre and post hooks either side of the system's event dispatch code.- Overrides:
dispatchEvent
in classEventQueue
-
preDispatchEvent
Starts tracking a dispatch. -
postDispatchEvent
Stops tracking a dispatch. -
checkForDeadlock
-
stackTraceToString
-
getNewHangNumber
-
main
-