1.1 --- a/src/share/classes/java/awt/EventQueue.java Mon Sep 26 17:59:52 2011 +0400
1.2 +++ b/src/share/classes/java/awt/EventQueue.java Wed May 23 11:51:09 2012 +0200
1.3 @@ -299,9 +299,9 @@
1.4 if (theEvent.getSource() != AWTAutoShutdown.getInstance()) {
1.5 AWTAutoShutdown.getInstance().notifyThreadBusy(dispatchThread);
1.6 }
1.7 - pushPopCond.signalAll();
1.8 + signalAll();
1.9 } else if (notifyID) {
1.10 - pushPopCond.signalAll();
1.11 + signalAll();
1.12 }
1.13 } else {
1.14 // The event was not coalesced or has non-Component source.
1.15 @@ -309,7 +309,7 @@
1.16 queues[priority].tail.next = newItem;
1.17 queues[priority].tail = newItem;
1.18 if (notifyID) {
1.19 - pushPopCond.signalAll();
1.20 + signalAll();
1.21 }
1.22 }
1.23 }
1.24 @@ -484,6 +484,31 @@
1.25
1.26 return true;
1.27 }
1.28 +
1.29 + final AWTEvent getNextEvent(int id, boolean block) throws InterruptedException {
1.30 + if (block) {
1.31 + return (id == EventDispatchThread.ANY_EVENT) ? getNextEvent() : getNextEvent(id);
1.32 + }
1.33 + try {
1.34 + pushPopLock.lock();
1.35 + if (id == EventDispatchThread.ANY_EVENT) {
1.36 + if (noEvents()) {
1.37 + return null;
1.38 + }
1.39 + // XXX: calls SunToolkit.flushPendingEvents under lock now
1.40 + return getNextEvent();
1.41 + } else {
1.42 + AWTEvent peek = peekEvent(id);
1.43 + if (peek == null) {
1.44 + return null;
1.45 + }
1.46 + // XXX: calls SunToolkit.flushPendingEvents under lock now
1.47 + return getNextEvent(id);
1.48 + }
1.49 + } finally {
1.50 + pushPopLock.unlock();
1.51 + }
1.52 + }
1.53
1.54 /**
1.55 * Removes an event from the <code>EventQueue</code> and
1.56 @@ -853,7 +878,7 @@
1.57 appContext.put(AppContext.EVENT_QUEUE_KEY, newEventQueue);
1.58 }
1.59
1.60 - pushPopCond.signalAll();
1.61 + signalAll();
1.62 } finally {
1.63 pushPopLock.unlock();
1.64 }
1.65 @@ -918,7 +943,7 @@
1.66 // pick up a new EventQueue
1.67 topQueue.postEventPrivate(new InvocationEvent(topQueue, dummyRunnable));
1.68
1.69 - pushPopCond.signalAll();
1.70 + signalAll();
1.71 } finally {
1.72 pushPopLock.unlock();
1.73 }
1.74 @@ -1010,16 +1035,14 @@
1.75 EventDispatchThread t =
1.76 new EventDispatchThread(threadGroup,
1.77 name,
1.78 - EventQueue.this);
1.79 - t.setContextClassLoader(classLoader);
1.80 - t.setPriority(Thread.NORM_PRIORITY + 1);
1.81 - t.setDaemon(false);
1.82 + EventQueue.this,
1.83 + classLoader
1.84 + );
1.85 return t;
1.86 }
1.87 }
1.88 );
1.89 AWTAutoShutdown.getInstance().notifyThreadBusy(dispatchThread);
1.90 - dispatchThread.start();
1.91 }
1.92 } finally {
1.93 pushPopLock.unlock();
1.94 @@ -1252,7 +1275,7 @@
1.95 // Forward call to the top of EventQueue stack.
1.96 nextQueue.wakeup(isShutdown);
1.97 } else if (dispatchThread != null) {
1.98 - pushPopCond.signalAll();
1.99 + signalAll();
1.100 } else if (!isShutdown) {
1.101 initDispatchThread();
1.102 }
1.103 @@ -1260,8 +1283,15 @@
1.104 pushPopLock.unlock();
1.105 }
1.106 }
1.107 +
1.108 + private void signalAll() {
1.109 + pushPopCond.signalAll();
1.110 +
1.111 + // new event delivered - requesting new processing
1.112 + // of pending events
1.113 + dispatchThread.processEvents();
1.114 + }
1.115 }
1.116 -
1.117 /**
1.118 * The Queue object holds pointers to the beginning and end of one internal
1.119 * queue. An EventQueue object is composed of multiple internal Queues, one