jdk/src/share/classes/java/awt/EventQueue.java
changeset 3938 ef327bd847c0
parent 3084 67ca55732362
child 3972 8942e64cf57d
equal deleted inserted replaced
3934:487e1aa949c4 3938:ef327bd847c0
    34 
    34 
    35 import java.security.AccessController;
    35 import java.security.AccessController;
    36 import java.security.PrivilegedAction;
    36 import java.security.PrivilegedAction;
    37 
    37 
    38 import java.util.EmptyStackException;
    38 import java.util.EmptyStackException;
    39 import java.util.logging.*;
    39 import sun.util.logging.PlatformLogger;
    40 
    40 
    41 import sun.awt.AppContext;
    41 import sun.awt.AppContext;
    42 import sun.awt.AWTAutoShutdown;
    42 import sun.awt.AWTAutoShutdown;
    43 import sun.awt.PeerEvent;
    43 import sun.awt.PeerEvent;
    44 import sun.awt.SunToolkit;
    44 import sun.awt.SunToolkit;
   151      */
   151      */
   152     private int waitForID;
   152     private int waitForID;
   153 
   153 
   154     private final String name = "AWT-EventQueue-" + nextThreadNum();
   154     private final String name = "AWT-EventQueue-" + nextThreadNum();
   155 
   155 
   156     private static final Logger eventLog = Logger.getLogger("java.awt.event.EventQueue");
   156     private static final PlatformLogger eventLog = PlatformLogger.getLogger("java.awt.event.EventQueue");
   157 
   157 
   158     static {
   158     static {
   159         AWTAccessor.setEventQueueAccessor(
   159         AWTAccessor.setEventQueueAccessor(
   160             new AWTAccessor.EventQueueAccessor() {
   160             new AWTAccessor.EventQueueAccessor() {
   161                 public EventQueue getNextQueue(EventQueue eventQueue) {
   161                 public EventQueue getNextQueue(EventQueue eventQueue) {
   705      * @see      java.awt.EventQueue#pop
   705      * @see      java.awt.EventQueue#pop
   706      * @throws NullPointerException if <code>newEventQueue</code> is <code>null</code>
   706      * @throws NullPointerException if <code>newEventQueue</code> is <code>null</code>
   707      * @since           1.2
   707      * @since           1.2
   708      */
   708      */
   709     public synchronized void push(EventQueue newEventQueue) {
   709     public synchronized void push(EventQueue newEventQueue) {
   710         if (eventLog.isLoggable(Level.FINE)) {
   710         if (eventLog.isLoggable(PlatformLogger.FINE)) {
   711             eventLog.log(Level.FINE, "EventQueue.push(" + newEventQueue + ")");
   711             eventLog.fine("EventQueue.push(" + newEventQueue + ")");
   712         }
   712         }
   713 
   713 
   714         if (nextQueue != null) {
   714         if (nextQueue != null) {
   715             nextQueue.push(newEventQueue);
   715             nextQueue.push(newEventQueue);
   716             return;
   716             return;
   720             // Transfer all events forward to new EventQueue.
   720             // Transfer all events forward to new EventQueue.
   721             while (peekEvent() != null) {
   721             while (peekEvent() != null) {
   722                 try {
   722                 try {
   723                     newEventQueue.postEventPrivate(getNextEvent());
   723                     newEventQueue.postEventPrivate(getNextEvent());
   724                 } catch (InterruptedException ie) {
   724                 } catch (InterruptedException ie) {
   725                     if (eventLog.isLoggable(Level.FINE)) {
   725                     if (eventLog.isLoggable(PlatformLogger.FINE)) {
   726                         eventLog.log(Level.FINE, "Interrupted push", ie);
   726                         eventLog.fine("Interrupted push", ie);
   727                     }
   727                     }
   728                 }
   728                 }
   729             }
   729             }
   730 
   730 
   731             newEventQueue.previousQueue = this;
   731             newEventQueue.previousQueue = this;
   764      *  on this <code>EventQueue</code>
   764      *  on this <code>EventQueue</code>
   765      * @see      java.awt.EventQueue#push
   765      * @see      java.awt.EventQueue#push
   766      * @since           1.2
   766      * @since           1.2
   767      */
   767      */
   768     protected void pop() throws EmptyStackException {
   768     protected void pop() throws EmptyStackException {
   769         if (eventLog.isLoggable(Level.FINE)) {
   769         if (eventLog.isLoggable(PlatformLogger.FINE)) {
   770             eventLog.log(Level.FINE, "EventQueue.pop(" + this + ")");
   770             eventLog.fine("EventQueue.pop(" + this + ")");
   771         }
   771         }
   772 
   772 
   773         // To prevent deadlock, we lock on the previous EventQueue before
   773         // To prevent deadlock, we lock on the previous EventQueue before
   774         // this one.  This uses the same locking order as everything else
   774         // this one.  This uses the same locking order as everything else
   775         // in EventQueue.java, so deadlock isn't possible.
   775         // in EventQueue.java, so deadlock isn't possible.
   788             previousQueue.nextQueue = null;
   788             previousQueue.nextQueue = null;
   789             while (peekEvent() != null) {
   789             while (peekEvent() != null) {
   790                 try {
   790                 try {
   791                     previousQueue.postEventPrivate(getNextEvent());
   791                     previousQueue.postEventPrivate(getNextEvent());
   792                 } catch (InterruptedException ie) {
   792                 } catch (InterruptedException ie) {
   793                     if (eventLog.isLoggable(Level.FINE)) {
   793                     if (eventLog.isLoggable(PlatformLogger.FINE)) {
   794                         eventLog.log(Level.FINE, "Interrupted pop", ie);
   794                         eventLog.fine("Interrupted pop", ie);
   795                     }
   795                     }
   796                 }
   796                 }
   797             }
   797             }
   798             AppContext appContext = AppContext.getAppContext();
   798             AppContext appContext = AppContext.getAppContext();
   799             if (appContext.get(AppContext.EVENT_QUEUE_KEY) == this) {
   799             if (appContext.get(AppContext.EVENT_QUEUE_KEY) == this) {