posted 19 years ago
This is from some pdf file. It may help you.
There are a couple of concepts concerning finalize() :
1. For any given object, finalize() will be called only once by the
garbage collector.
2. Calling finalize() can actually result in saving an object from deletion.
First of all, finalize() is a method, and any code that you can put into a normal method you can put into finalize(). For example, in the finalize() method you could write code that passes a reference to the object in question back to another object, effectively 'uneligiblizing' the object for garbage collection. If at some point later on this same object becomes eligible for garbage collection again, the garbage collector can still process this object and delete it.
The garbage collector, however,will remember that, for this object, finalize() already ran, and it will not run finalize() again.