src/share/classes/java/awt/EventQueue.java

Print this page

        

@@ -179,11 +179,18 @@
      */
     private final AppContext appContext;
 
     private final String name = "AWT-EventQueue-" + threadInitNumber.getAndIncrement();
 
-    private static final PlatformLogger eventLog = PlatformLogger.getLogger("java.awt.event.EventQueue");
+    private static volatile PlatformLogger eventLog;
+
+    private static final PlatformLogger getEventLog() {
+        if(eventLog == null) {
+            eventLog = PlatformLogger.getLogger("java.awt.event.EventQueue");
+        }
+        return eventLog;
+    }
 
     static {
         AWTAccessor.setEventQueueAccessor(
             new AWTAccessor.EventQueueAccessor() {
                 public Thread getDispatchThread(EventQueue eventQueue) {

@@ -746,12 +753,12 @@
         } else if (src instanceof AWTAutoShutdown) {
             if (noEvents()) {
                 dispatchThread.stopDispatching();
             }
         } else {
-            if (eventLog.isLoggable(PlatformLogger.FINE)) {
-                eventLog.fine("Unable to dispatch event: " + event);
+            if (getEventLog().isLoggable(PlatformLogger.FINE)) {
+                getEventLog().fine("Unable to dispatch event: " + event);
             }
         }
     }
 
     /**

@@ -844,12 +851,12 @@
      * @see      java.awt.EventQueue#pop
      * @throws NullPointerException if <code>newEventQueue</code> is <code>null</code>
      * @since           1.2
      */
     public void push(EventQueue newEventQueue) {
-        if (eventLog.isLoggable(PlatformLogger.FINE)) {
-            eventLog.fine("EventQueue.push(" + newEventQueue + ")");
+        if (getEventLog().isLoggable(PlatformLogger.FINE)) {
+            getEventLog().fine("EventQueue.push(" + newEventQueue + ")");
         }
 
         pushPopLock.lock();
         try {
             EventQueue topQueue = this;

@@ -868,12 +875,12 @@
             while (topQueue.peekEvent() != null) {
                 try {
                     // Use getNextEventPrivate() as it doesn't call flushPendingEvents()
                     newEventQueue.postEventPrivate(topQueue.getNextEventPrivate());
                 } catch (InterruptedException ie) {
-                    if (eventLog.isLoggable(PlatformLogger.FINE)) {
-                        eventLog.fine("Interrupted push", ie);
+                    if (getEventLog().isLoggable(PlatformLogger.FINE)) {
+                        getEventLog().fine("Interrupted push", ie);
                     }
                 }
             }
 
             // Wake up EDT waiting in getNextEvent(), so it can

@@ -907,12 +914,12 @@
      *  on this <code>EventQueue</code>
      * @see      java.awt.EventQueue#push
      * @since           1.2
      */
     protected void pop() throws EmptyStackException {
-        if (eventLog.isLoggable(PlatformLogger.FINE)) {
-            eventLog.fine("EventQueue.pop(" + this + ")");
+        if (getEventLog().isLoggable(PlatformLogger.FINE)) {
+            getEventLog().fine("EventQueue.pop(" + this + ")");
         }
 
         pushPopLock.lock();
         try {
             EventQueue topQueue = this;

@@ -930,12 +937,12 @@
             // Transfer all events back to previous EventQueue.
             while (topQueue.peekEvent() != null) {
                 try {
                     prevQueue.postEventPrivate(topQueue.getNextEventPrivate());
                 } catch (InterruptedException ie) {
-                    if (eventLog.isLoggable(PlatformLogger.FINE)) {
-                        eventLog.fine("Interrupted pop", ie);
+                    if (getEventLog().isLoggable(PlatformLogger.FINE)) {
+                        getEventLog().fine("Interrupted pop", ie);
                     }
                 }
             }
 
             if ((topQueue.dispatchThread != null) &&