Thursday, October 18, 2007

Finalizer guardian Idiom

Finalizer Guardian idiom is nothing but an anonymous class assigned to a private final instance variable within a class that wants to override the finalize method .

The anonymous class takes the responsibility of calling the finalize method of the enclosing class.
All this in code looks like :

public class A{
private final Object b = new Object(){
protected void finalize() throws Throwable {
// finalize the outer A here
}
};
}

No comments: