6699589: java/awt/EventQueue/PostEventOrderingTest.java fails
authorart
Wed, 26 Nov 2008 16:25:16 +0300
changeset 1973 1c56524d207d
parent 1972 8aeb4ecbfa44
child 1974 1e1487c04864
6699589: java/awt/EventQueue/PostEventOrderingTest.java fails Reviewed-by: dav, anthony
jdk/src/share/classes/sun/awt/SunToolkit.java
--- a/jdk/src/share/classes/sun/awt/SunToolkit.java	Tue Oct 28 17:06:12 2008 +0300
+++ b/jdk/src/share/classes/sun/awt/SunToolkit.java	Wed Nov 26 16:25:16 2008 +0300
@@ -2008,26 +2008,12 @@
     /*
      * Continually post pending AWTEvents to the Java EventQueue.
      */
-    public void flush() {
-        if (queueHead != null) {
-            EventQueueItem tempQueue;
-            /*
-             * We have to execute the loop inside the synchronized block
-             * to ensure that the flush is completed before a new event
-             * can be posted to this queue.
-             */
-            synchronized (this) {
-                tempQueue = queueHead;
-                queueHead = queueTail = null;
-                /*
-                 * If this PostEventQueue is flushed in parallel on two
-                 * different threads tempQueue will be null for one of them.
-                 */
-                while (tempQueue != null) {
-                    eventQueue.postEvent(tempQueue.event);
-                    tempQueue = tempQueue.next;
-                }
-            }
+    public synchronized void flush() {
+        EventQueueItem tempQueue = queueHead;
+        queueHead = queueTail = null;
+        while (tempQueue != null) {
+            eventQueue.postEvent(tempQueue.event);
+            tempQueue = tempQueue.next;
         }
     }