|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjava.awt.EventQueue
hmi.util.EventDispatchThreadHangMonitor
public final class 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.
| Nested Class Summary | |
|---|---|
private class |
EventDispatchThreadHangMonitor.HangChecker
TimerTask that executes checks for hanging |
| Field Summary | |
|---|---|
private static long |
CHECK_INTERVAL_MS
|
private Thread |
eventDispatchThread
|
private static EventQueue |
INSTANCE
|
private static long |
NO_CURRENT_EVENT
|
private boolean |
reportedHang
|
private long |
startedLastEventDispatchAt
|
private static long |
UNREASONABLE_DISPATCH_DURATION_MS
|
| Constructor Summary | |
|---|---|
private |
EventDispatchThreadHangMonitor()
|
| Method Summary | |
|---|---|
protected void |
dispatchEvent(AWTEvent event)
Overrides EventQueue.dispatchEvent to call our pre and post hooks either side of the system's event dispatch code. |
Thread |
getEventDispatchThread()
|
boolean |
getReportedHang()
|
long |
getStartedLastEventDispatchAt()
|
static void |
initMonitoring()
Sets up hang detection for the event dispatch thread. |
private void |
initTimer()
Sets up a timer to check for hangs frequently. |
private void |
postDispatchEvent()
Reports the end of any ongoing hang, and notes that we're no longer processing an event. |
private void |
preDispatchEvent()
Stores the time at which we started processing the current event. |
void |
setReportedHang(boolean val)
|
private long |
timeSoFar()
Returns how long we've been processing the current event (in milliseconds). |
| Methods inherited from class java.awt.EventQueue |
|---|
getCurrentEvent, getMostRecentEventTime, getNextEvent, invokeAndWait, invokeLater, isDispatchThread, peekEvent, peekEvent, pop, postEvent, push |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
private static final EventQueue INSTANCE
private static final long CHECK_INTERVAL_MS
private static final long UNREASONABLE_DISPATCH_DURATION_MS
private static final long NO_CURRENT_EVENT
private long startedLastEventDispatchAt
private boolean reportedHang
private Thread eventDispatchThread
| Constructor Detail |
|---|
private EventDispatchThreadHangMonitor()
| Method Detail |
|---|
public long getStartedLastEventDispatchAt()
public Thread getEventDispatchThread()
public boolean getReportedHang()
public void setReportedHang(boolean val)
private void initTimer()
private long timeSoFar()
public static void initMonitoring()
protected void dispatchEvent(AWTEvent event)
dispatchEvent in class EventQueueprivate void preDispatchEvent()
private void postDispatchEvent()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||