When is the finalize() method called in Java? -
i need know when finalize()
method called in jvm
. created test class writes file when finalize()
method called overriding it. not executed. can tell me reason why not executing?
in general it's best not rely on finalize()
cleaning etc.
according javadoc (which worth reading), is:
called garbage collector on object when garbage collection determines there no more references object.
as joachim pointed out, may never happen in life of program if object accessible.
also, garbage collector not guaranteed run @ specific time. in general, i'm trying finalize()
not best method use in general unless there's specific need for.
Comments
Post a Comment