diff --git a/src/share/classes/java/util/concurrent/locks/AbstractQueuedLongSynchronizer.java b/src/share/classes/java/util/concurrent/locks/AbstractQueuedLongSynchronizer.java index 2b0f36c523d1c9b9288ef1af0d684eb45dbb062c..a7f048e8bdb13e52a64e0d864246ad06f45b3b5e 100644 --- a/src/share/classes/java/util/concurrent/locks/AbstractQueuedLongSynchronizer.java +++ b/src/share/classes/java/util/concurrent/locks/AbstractQueuedLongSynchronizer.java @@ -1222,8 +1222,10 @@ public abstract class AbstractQueuedLongSynchronizer // The correctness of this depends on head being initialized // before tail and on head.next being accurate if the current // thread is first in queue. - Node h, s; - return (h = head) != tail && + Node t = tail; // Read fields in reverse initialization order + Node h = head; + Node s; + return h != t && ((s = h.next) == null || s.thread != Thread.currentThread()); } diff --git a/src/share/classes/java/util/concurrent/locks/AbstractQueuedSynchronizer.java b/src/share/classes/java/util/concurrent/locks/AbstractQueuedSynchronizer.java index 597e15270aeedade66625fceb30ae5ed368c48c9..39219bb5fd9111950c61c46f9eb02631f382190e 100644 --- a/src/share/classes/java/util/concurrent/locks/AbstractQueuedSynchronizer.java +++ b/src/share/classes/java/util/concurrent/locks/AbstractQueuedSynchronizer.java @@ -1445,8 +1445,10 @@ public abstract class AbstractQueuedSynchronizer // The correctness of this depends on head being initialized // before tail and on head.next being accurate if the current // thread is first in queue. - Node h, s; - return (h = head) != tail && + Node t = tail; // Read fields in reverse initialization order + Node h = head; + Node s; + return h != t && ((s = h.next) == null || s.thread != Thread.currentThread()); }