Hi Dave,
There are also four additional objects created in lines 3 & 4 of m1() that also become eligible for garbage collection.
There are no more objects created in lines 3 & 4 of m1(). Perhaps, you mean there are four other references made to the four objects in lines 3 & 4 of m1()?
Even though the references to those objects (the ones created in lines 3 & 4) never go away, they become eligible because the references to the objects they are contained in go away, so no existing thread has access to them. Is this correct, or am I off here?
The keyword here,
no live thread has access to them. So, you are correct that even though there are still references to the four objects other than i1, i2, i3, and i4, (as a result of lines 3 & 4 of m1()), but because they merely points to each other/itself, and no other live thread can access them, they become eligible for GC.
Hope this helps.
[ February 20, 2004: Message edited by: David Hadiprijanto ]