--- a/src/share/classes/java/awt/EventDispatchThread.java Tue Oct 02 12:14:45 2012 +0100
+++ b/src/share/classes/java/awt/EventDispatchThread.java Wed Aug 22 15:07:26 2012 +0400
@@ -67,8 +67,7 @@ class EventDispatchThread extends Thread
private static final PlatformLogger eventLog = PlatformLogger.getLogger("java.awt.event.EventDispatchThread");
private EventQueue theQueue;
- private boolean doDispatch = true;
- private volatile boolean shutdown = false;
+ private volatile boolean doDispatch = true;
private static final int ANY_EVENT = -1;
@@ -84,11 +83,6 @@ class EventDispatchThread extends Thread
*/
public void stopDispatching() {
doDispatch = false;
- }
-
- public void interrupt() {
- shutdown = true;
- super.interrupt();
}
public void run() {
@@ -100,7 +94,12 @@ class EventDispatchThread extends Thread
}
});
} finally {
- if(getEventQueue().detachDispatchThread(this, shutdown)) {
+ // 7189350: doDispatch is reset from stopDispatching(),
+ // on InterruptedException, or ThreadDeath. Either way,
+ // this indicates that we must force shutting down.
+ if (getEventQueue().detachDispatchThread(this,
+ !doDispatch || isInterrupted()))
+ {
break;
}
}
@@ -158,8 +157,7 @@ class EventDispatchThread extends Thread
void pumpEventsForFilter(int id, Conditional cond, EventFilter filter) {
addEventFilter(filter);
doDispatch = true;
- shutdown |= isInterrupted();
- while (doDispatch && !shutdown && cond.evaluate()) {
+ while (doDispatch && !isInterrupted() && cond.evaluate()) {
pumpOneEventForFilters(id);
}
removeEventFilter(filter);
@@ -247,12 +245,12 @@ class EventDispatchThread extends Thread
}
}
catch (ThreadDeath death) {
- shutdown = true;
+ doDispatch = false;
throw death;
}
catch (InterruptedException interruptedException) {
- shutdown = true; // AppContext.dispose() interrupts all
- // Threads in the AppContext
+ doDispatch = false; // AppContext.dispose() interrupts all
+ // Threads in the AppContext
}
catch (Throwable e) {
processException(e);