Synchronize DestructorThread construction
Summary: We think that sThread may not have access to mHead, which Synchronization will force
@@ -56,12 +56,12 @@ public class DestructorThread {
}
/** A list to keep all active Destructors in memory confined to the Destructor thread. */
- private static DestructorList sDestructorList;
+ private static final DestructorList sDestructorList;
/** A thread safe stack where new Destructors are placed before being add to sDestructorList. */
- private static DestructorStack sDestructorStack;
+ private static final DestructorStack sDestructorStack;
- private static ReferenceQueue sReferenceQueue;
- private static Thread sThread;
+ private static final ReferenceQueue sReferenceQueue;
+ private static final Thread sThread;
static {
sDestructorStack = new DestructorStack();
@@ -102,7 +102,7 @@ public class DestructorThread {
/** This is a thread safe, lock-free Treiber-like Stack of Destructors. */
private static class DestructorStack {
- private AtomicReference<Destructor> mHead = new AtomicReference<>();
+ private final AtomicReference<Destructor> mHead = new AtomicReference<>();
public void push(Destructor newHead) {
Destructor oldHead;
@@ -124,7 +124,7 @@ public class DestructorThread {
/** A doubly-linked list of Destructors. */
private static class DestructorList {
- private Destructor mHead;
+ private final Destructor mHead;
public DestructorList() {
mHead = new Terminus();
