Forum

Number Of Page View:100,000+/Months
LOGIN |New User

Reply

Isolating a Reference
its a diff way for the objects can become eligible for garbage collection even if they still have valid references!.We also know that the islands of isolation.we have a code its very somple example for the call instance .......following here  : 

 public class Island {
Island a;
public static void main(String [] args) {
Island a2 = new Island();
Island a3 = new Island();
Island a4 = new Island();
a2.a = a3; // a2 refers to a3
a3.a = a4; // a3 refers to a4
a4.a = a2; // a4 refers to a2
a2 = null;
a3 = null;
a4 = null;
// do complicated, memory intensive stuff
}
}
        When the code reaches // do complicated, the three Island objectshave instance variables so that they refer to each other, but their links to the outside world have been nulled. These three objects are eligible for garbage collection.
Posted By: Name:Rajesh Kr URL: Isolating a Reference