The line you added
this.a=this;
is not something that will prevent A
from being GC, this object is still not being referenced from something valid like a live thread.
Try looking at a more complex structure: List
if you point the last node to the first (circular list), and then to set your Node head = null;
then maybe each node is still being pointed from the other node but the whole List is not being referenced from a live thread and there for will be garbage collected.
Garbage collector is not just checking if the object is being referenced, but deep checking if there is a reference from a valid thread.
Bottom line is:
If an object is unreachable from a thread it's garbage collected. In your case A is not reachable any more.