File tree Expand file tree Collapse file tree 1 file changed +3
-8
lines changed
jcl/src/java.base/share/classes/java/lang/ref Expand file tree Collapse file tree 1 file changed +3
-8
lines changed Original file line number Diff line number Diff line change @@ -60,7 +60,7 @@ public abstract sealed class Reference<T> extends Object permits PhantomReferenc
60
60
61
61
private T referent ;
62
62
private ReferenceQueue queue ;
63
- private int state ;
63
+ private volatile int state ;
64
64
65
65
/* jdk.lang.ref.disableClearBeforeEnqueue property allow reverting to the old behavior(non clear before enqueue)
66
66
* defer initializing the immutable variable to avoid bootstrap error
@@ -181,9 +181,7 @@ public T get() {
181
181
@ Deprecated (since ="16" )
182
182
/*[ENDIF] JAVA_SPEC_VERSION >= 16 */
183
183
public boolean isEnqueued () {
184
- synchronized (this ) {
185
- return state == STATE_ENQUEUED ;
186
- }
184
+ return state == STATE_ENQUEUED ;
187
185
}
188
186
189
187
/**
@@ -255,10 +253,7 @@ void initReference (T r, ReferenceQueue q) {
255
253
* Set the enqueued field to false.
256
254
*/
257
255
void dequeue () {
258
- /*[PR 112508] not synchronized, so isEnqueued() could return wrong result */
259
- synchronized (this ) {
260
- state = STATE_CLEARED ;
261
- }
256
+ state = STATE_CLEARED ;
262
257
}
263
258
264
259
/*[IF JAVA_SPEC_VERSION >= 9]*/
You can’t perform that action at this time.
0 commit comments