diff --git a/jdk/src/share/classes/java/awt/EventDispatchThread.java b/jdk/src/share/classes/java/awt/EventDispatchThread.java index ab1d3e6f70a..51344658c7e 100644 --- a/jdk/src/share/classes/java/awt/EventDispatchThread.java +++ b/jdk/src/share/classes/java/awt/EventDispatchThread.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,19 +25,11 @@ package java.awt; -import java.awt.event.InputEvent; import java.awt.event.MouseEvent; import java.awt.event.ActionEvent; import java.awt.event.WindowEvent; -import java.lang.reflect.Method; -import java.security.AccessController; -import sun.security.action.GetPropertyAction; -import sun.awt.AWTAutoShutdown; -import sun.awt.SunToolkit; -import sun.awt.AppContext; import java.util.ArrayList; -import java.util.List; import sun.util.logging.PlatformLogger; import sun.awt.dnd.SunDragSourceContextPeer; @@ -67,8 +59,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; @@ -86,24 +77,15 @@ class EventDispatchThread extends Thread { doDispatch = false; } - public void interrupt() { - shutdown = true; - super.interrupt(); - } - public void run() { - while (true) { - try { - pumpEvents(new Conditional() { - public boolean evaluate() { - return true; - } - }); - } finally { - if(getEventQueue().detachDispatchThread(this, shutdown)) { - break; + try { + pumpEvents(new Conditional() { + public boolean evaluate() { + return true; } - } + }); + } finally { + getEventQueue().detachDispatchThread(this); } } @@ -130,8 +112,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); @@ -223,12 +204,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); diff --git a/jdk/src/share/classes/java/awt/EventQueue.java b/jdk/src/share/classes/java/awt/EventQueue.java index 8c144ebc889..af9e1bf08f3 100644 --- a/jdk/src/share/classes/java/awt/EventQueue.java +++ b/jdk/src/share/classes/java/awt/EventQueue.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -1074,7 +1074,7 @@ public class EventQueue { } } - final boolean detachDispatchThread(EventDispatchThread edt, boolean forceDetach) { + final void detachDispatchThread(EventDispatchThread edt) { /* * Minimize discard possibility for non-posted events */ @@ -1090,17 +1090,9 @@ public class EventQueue { pushPopLock.lock(); try { if (edt == dispatchThread) { - /* - * Don't detach the thread if any events are pending. Not - * sure if it's a possible scenario, though. - */ - if (!forceDetach && (peekEvent() != null)) { - return false; - } dispatchThread = null; } AWTAutoShutdown.getInstance().notifyThreadFree(edt); - return true; } finally { pushPopLock.unlock(); }