changeset 1494:5b166df43d63

6837293: Reapply fix for 6588003 to JDK7 Reviewed-by: alexp
author peterz
date Tue, 05 May 2009 12:07:37 +0400
parents 903ce4bda292
children ead34d1e3c9f
files src/share/classes/javax/swing/text/LayoutQueue.java
diffstat 1 files changed, 15 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/classes/javax/swing/text/LayoutQueue.java	Wed Apr 29 11:43:19 2009 -0700
+++ b/src/share/classes/javax/swing/text/LayoutQueue.java	Tue May 05 12:07:37 2009 +0400
@@ -25,6 +25,7 @@
 package javax.swing.text;
 
 import java.util.Vector;
+import sun.awt.AppContext;
 
 /**
  * A queue of text layout tasks.
@@ -35,10 +36,10 @@
  */
 public class LayoutQueue {
 
-    Vector<Runnable> tasks;
-    Thread worker;
+    private static final Object DEFAULT_QUEUE = new Object();
 
-    static LayoutQueue defaultQueue;
+    private Vector<Runnable> tasks;
+    private Thread worker;
 
     /**
      * Construct a layout queue.
@@ -51,10 +52,15 @@
      * Fetch the default layout queue.
      */
     public static LayoutQueue getDefaultQueue() {
-        if (defaultQueue == null) {
-            defaultQueue = new LayoutQueue();
+        AppContext ac = AppContext.getAppContext();
+        synchronized (DEFAULT_QUEUE) {
+            LayoutQueue defaultQueue = (LayoutQueue) ac.get(DEFAULT_QUEUE);
+            if (defaultQueue == null) {
+                defaultQueue = new LayoutQueue();
+                ac.put(DEFAULT_QUEUE, defaultQueue);
+            }
+            return defaultQueue;
         }
-        return defaultQueue;
     }
 
     /**
@@ -63,7 +69,9 @@
      * @param q the new queue.
      */
     public static void setDefaultQueue(LayoutQueue q) {
-        defaultQueue = q;
+        synchronized (DEFAULT_QUEUE) {
+            AppContext.getAppContext().put(DEFAULT_QUEUE, q);
+        }
     }
 
     /**