6699589: java/awt/EventQueue/PostEventOrderingTest.java fails

Reviewed-by: dav, anthony
This commit is contained in:
Artem Ananiev 2008-11-26 16:25:16 +03:00
parent dacdf4a500
commit 4121a03c4c

View File

@ -2008,28 +2008,14 @@ class PostEventQueue {
/* /*
* Continually post pending AWTEvents to the Java EventQueue. * Continually post pending AWTEvents to the Java EventQueue.
*/ */
public void flush() { public synchronized void flush() {
if (queueHead != null) { EventQueueItem tempQueue = queueHead;
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; 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) { while (tempQueue != null) {
eventQueue.postEvent(tempQueue.event); eventQueue.postEvent(tempQueue.event);
tempQueue = tempQueue.next; tempQueue = tempQueue.next;
} }
} }
}
}
/* /*
* Enqueue an AWTEvent to be posted to the Java EventQueue. * Enqueue an AWTEvent to be posted to the Java EventQueue.