jdk/src/share/classes/java/lang/ref/ReferenceQueue.java
changeset 2442 f8bb207f9458
parent 2 90ce3da70b43
child 5506 202f599c92aa
--- a/jdk/src/share/classes/java/lang/ref/ReferenceQueue.java	Thu Apr 02 11:13:56 2009 +0100
+++ b/jdk/src/share/classes/java/lang/ref/ReferenceQueue.java	Thu Apr 02 11:19:34 2009 +0100
@@ -51,7 +51,7 @@
 
     static private class Lock { };
     private Lock lock = new Lock();
-    private Reference<? extends T> head = null;
+    private volatile Reference<? extends T> head = null;
     private long queueLength = 0;
 
     boolean enqueue(Reference<? extends T> r) { /* Called only by Reference class */
@@ -95,6 +95,8 @@
      *          otherwise <code>null</code>
      */
     public Reference<? extends T> poll() {
+        if (head == null)
+            return null;
         synchronized (lock) {
             return reallyPoll();
         }