jdk/src/share/classes/sun/awt/SunToolkit.java
changeset 1973 1c56524d207d
parent 1190 f27065d0d9f0
child 1978 8b981ce05cd0
equal deleted inserted replaced
1972:8aeb4ecbfa44 1973:1c56524d207d
  2006     }
  2006     }
  2007 
  2007 
  2008     /*
  2008     /*
  2009      * Continually post pending AWTEvents to the Java EventQueue.
  2009      * Continually post pending AWTEvents to the Java EventQueue.
  2010      */
  2010      */
  2011     public void flush() {
  2011     public synchronized void flush() {
  2012         if (queueHead != null) {
  2012         EventQueueItem tempQueue = queueHead;
  2013             EventQueueItem tempQueue;
  2013         queueHead = queueTail = null;
  2014             /*
  2014         while (tempQueue != null) {
  2015              * We have to execute the loop inside the synchronized block
  2015             eventQueue.postEvent(tempQueue.event);
  2016              * to ensure that the flush is completed before a new event
  2016             tempQueue = tempQueue.next;
  2017              * can be posted to this queue.
       
  2018              */
       
  2019             synchronized (this) {
       
  2020                 tempQueue = queueHead;
       
  2021                 queueHead = queueTail = null;
       
  2022                 /*
       
  2023                  * If this PostEventQueue is flushed in parallel on two
       
  2024                  * different threads tempQueue will be null for one of them.
       
  2025                  */
       
  2026                 while (tempQueue != null) {
       
  2027                     eventQueue.postEvent(tempQueue.event);
       
  2028                     tempQueue = tempQueue.next;
       
  2029                 }
       
  2030             }
       
  2031         }
  2017         }
  2032     }
  2018     }
  2033 
  2019 
  2034     /*
  2020     /*
  2035      * Enqueue an AWTEvent to be posted to the Java EventQueue.
  2021      * Enqueue an AWTEvent to be posted to the Java EventQueue.