Take a look carefully in your code, in line 4 you're creating a new object and refering it with gc2, on line 5 you're creating a second object and refering it with gc3, on lines 6 and 7 you are crossing references, I mean you just are doing that both gc inside your two objects refer to each other, but in line 8 you are creating a new object, this object has its own gc, but it refers to NULL and you are refering it with gc2, finally you are refering this last object which its gc referes to NULL with gc3.
So both reference variables (gc2 and gc3) points to the same object (the one which its gc refers to NULL), the other two objects have no reference alive, you can think "but object1.gc refers to object2 and object2.gc refers to object1, so they still having references alive", the answer is no, since you have no an alive reference variable from your thread which refer to object1 there is no way to access object2 throught object1.gc and viceversa, so both objects have lost their connection to the world, indeed they are elegibles for garbage collector.
Do you get it? I hope this help you to understand it.
Also I want to encourage you to take a look around, there are so many cases about garbage collector in JavaRanch, some of them are quite similar to your doubt.
SCJP 5.0<br />Preparing SCWCD
Joined: Jun 06, 2007
Sorry Alejandro...that was my oversight.Thanks for clearing my doubt
Joined: Jan 02, 2008
Don't apologize, we all are here to learn and to ask each others; if don't, I would not answer you, I glad that I can help you. Just take a bit time to read other's questions, it helped to understand some things.