src/share/classes/java/lang/ref/Reference.java
Print this page
@@ -87,11 +87,11 @@
* field is also used for linking Reference objects in the pending list.
*/
private T referent; /* Treated specially by GC */
- ReferenceQueue<? super T> queue;
+ volatile ReferenceQueue<? super T> queue;
/* When active: NULL
* pending: this
* Enqueued: next reference in queue (or this if last)
* Inactive: this
@@ -223,13 +223,11 @@
*
* @return <code>true</code> if and only if this reference object has
* been enqueued
*/
public boolean isEnqueued() {
- synchronized (this) {
- return (this.next != null && this.queue == ReferenceQueue.ENQUEUED);
- }
+ return (this.queue == ReferenceQueue.ENQUEUED);
}
/**
* Adds this reference object to the queue with which it is registered,
* if any.