--- old/src/share/classes/java/awt/EventDispatchThread.java 2011-08-24 19:40:54.812675981 +0200 +++ new/src/share/classes/java/awt/EventDispatchThread.java 2011-08-24 19:40:54.539679392 +0200 @@ -34,8 +34,10 @@ import sun.security.action.GetPropertyAction; import sun.awt.AWTAutoShutdown; import sun.awt.SunToolkit; +import sun.awt.AppContext; -import java.util.Vector; +import java.util.ArrayList; +import java.util.List; import sun.util.logging.PlatformLogger; import sun.awt.dnd.SunDragSourceContextPeer; @@ -66,11 +68,11 @@ private EventQueue theQueue; private boolean doDispatch = true; - private boolean threadDeathCaught = false; + private volatile boolean shutdown = false; private static final int ANY_EVENT = -1; - private Vector eventFilters = new Vector(); + private ArrayList eventFilters = new ArrayList(); EventDispatchThread(ThreadGroup group, String name, EventQueue queue) { super(group, name); @@ -83,6 +85,11 @@ public void stopDispatching() { doDispatch = false; } + + public void interrupt() { + shutdown = true; + super.interrupt(); + } public void run() { while (true) { @@ -93,8 +100,7 @@ } }); } finally { - EventQueue eq = getEventQueue(); - if (eq.detachDispatchThread(this) || threadDeathCaught) { + if(getEventQueue().detachDispatchThread(this, shutdown)) { break; } } @@ -124,10 +130,8 @@ void pumpEventsForFilter(int id, Conditional cond, EventFilter filter) { addEventFilter(filter); doDispatch = true; - while (doDispatch && cond.evaluate()) { - if (isInterrupted() || !pumpOneEventForFilters(id)) { - doDispatch = false; - } + while (doDispatch && !shutdown && cond.evaluate()) { + pumpOneEventForFilters(id); } removeEventFilter(filter); } @@ -163,7 +167,7 @@ } } - boolean pumpOneEventForFilters(int id) { + void pumpOneEventForFilters(int id) { AWTEvent event = null; boolean eventOK = false; try { @@ -212,24 +216,17 @@ if (delegate != null) { delegate.afterDispatch(event, handle); } - - return true; } catch (ThreadDeath death) { - threadDeathCaught = true; - return false; - + shutdown = true; } catch (InterruptedException interruptedException) { - return false; // AppContext.dispose() interrupts all - // Threads in the AppContext - + shutdown = true; // AppContext.dispose() interrupts all + // Threads in the AppContext } catch (Throwable e) { processException(e); } - - return true; } private void processException(Throwable e) {