--- a/jdk/src/share/classes/java/awt/EventDispatchThread.java Wed Nov 25 22:14:30 2009 -0800
+++ b/jdk/src/share/classes/java/awt/EventDispatchThread.java Fri Nov 27 15:26:07 2009 +0300
@@ -104,11 +104,8 @@
} else {
stopEvent.dispatch();
}
- synchronized (theQueue) {
- if (theQueue.getDispatchThread() == this) {
- theQueue.detachDispatchThread();
- }
- }
+
+ theQueue.detachDispatchThread(this, false);
}
public void stopDispatching() {
@@ -142,35 +139,7 @@
}
});
} finally {
- /*
- * This synchronized block is to secure that the event dispatch
- * thread won't die in the middle of posting a new event to the
- * associated event queue. It is important because we notify
- * that the event dispatch thread is busy after posting a new event
- * to its queue, so the EventQueue.dispatchThread reference must
- * be valid at that point.
- */
- synchronized (theQueue) {
- if (theQueue.getDispatchThread() == this) {
- theQueue.detachDispatchThread();
- }
- /*
- * Event dispatch thread dies in case of an uncaught exception.
- * A new event dispatch thread for this queue will be started
- * only if a new event is posted to it. In case if no more
- * events are posted after this thread died all events that
- * currently are in the queue will never be dispatched.
- */
- /*
- * Fix for 4648733. Check both the associated java event
- * queue and the PostEventQueue.
- */
- if (theQueue.peekEvent() != null ||
- !SunToolkit.isPostEventQueueEmpty()) {
- theQueue.initDispatchThread();
- }
- AWTAutoShutdown.getInstance().notifyThreadFree(this);
- }
+ theQueue.detachDispatchThread(this, true);
}
}