If i have
public class Foo {
private boolean finalized = false;
public void foo() {
if (finalized)
throw new IllegalStateException("finalize() has been called.");
}
@Override public void finalize() {
super.finalize();
finalized = true;
}
}
Is this guaranteed even in the face of multiple threads, if only the GC calls finalize()that it IllegalStateExceptionwill never be selected?
I know that in the face of a method finalize()that causes an object not to collect garbage, the object will not be garbage collected, and other methods can be called. But that finalize()does not do it. Is there still an opportunity foo()to be called after finalize()?
source
share