6803402: Race condition in AbstractQueuedSynchronizer
Read fields in reverse initialization order Reviewed-by: martin
This commit is contained in:
parent
ee5c2301ec
commit
ca6e1aecc3
@ -1222,8 +1222,10 @@ public abstract class AbstractQueuedLongSynchronizer
|
|||||||
// The correctness of this depends on head being initialized
|
// The correctness of this depends on head being initialized
|
||||||
// before tail and on head.next being accurate if the current
|
// before tail and on head.next being accurate if the current
|
||||||
// thread is first in queue.
|
// thread is first in queue.
|
||||||
Node h, s;
|
Node t = tail; // Read fields in reverse initialization order
|
||||||
return (h = head) != tail &&
|
Node h = head;
|
||||||
|
Node s;
|
||||||
|
return h != t &&
|
||||||
((s = h.next) == null || s.thread != Thread.currentThread());
|
((s = h.next) == null || s.thread != Thread.currentThread());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1445,8 +1445,10 @@ public abstract class AbstractQueuedSynchronizer
|
|||||||
// The correctness of this depends on head being initialized
|
// The correctness of this depends on head being initialized
|
||||||
// before tail and on head.next being accurate if the current
|
// before tail and on head.next being accurate if the current
|
||||||
// thread is first in queue.
|
// thread is first in queue.
|
||||||
Node h, s;
|
Node t = tail; // Read fields in reverse initialization order
|
||||||
return (h = head) != tail &&
|
Node h = head;
|
||||||
|
Node s;
|
||||||
|
return h != t &&
|
||||||
((s = h.next) == null || s.thread != Thread.currentThread());
|
((s = h.next) == null || s.thread != Thread.currentThread());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user