2. Is the finalize() method guarenteed to be called exactly once before an object is garbage collected?
There is no guarantee the method is called at all, because the garbage collector may not collect the object. But, if it is called, it is called only once. Even if you uneligiblize the object in the finalize() code by assinging a (useful) reference to that object for example, the garbage collector remembers that finalize() was already called for that object and if that object becomes eligible again for the garbage collector, finalize is
not called again.
[ June 10, 2008: Message edited by: Ronald Schild ]