When I read the source code of Java AQS, I see the method acquireQueued
with annotation help gc
sets p.next = null
.
If it releases memory for p
, then why does it need to set p.next
to null
?
When I read the source code of Java AQS, I see the method acquireQueued
with annotation help gc
sets p.next = null
.
If it releases memory for p
, then why does it need to set p.next
to null
?
It means it's helping the garbage collector by setting that variable to null
, so that its previous value will become unreachable (assuming it's not reachable through some other variable) and thus collectible, without having to establish the unreachability of p
.