Author: Noel J. Bergman Java does not guarantee that finalizers run, and it certainly does not guarantee that they will run before Java decides to garbage collect that object.
Are you sure?
Java Language Specification, 12.6 Finalization of Class Instances
"Before the storage for an object is reclaimed by the garbage collector, the Java virtual machine will invoke the finalizer of that object."
"Before the storage for an object is reclaimed by the garbage collector, the Java virtual machine will invoke the finalizer of that object."
"The Java programming language does not specify how soon a finalizer will be invoked, except to say that it will happen before the storage for the object is reused."
http://java.sun.com/docs/books/jls/second_edition/html/execution.doc.html#44748
Interestingly the first quote says the finalizer method is invoked before the storage of the object is reclaimed and the second says that it is sometime before the storage is reused. I'd guess that this is getting into the nitty gritty of what the garbage collector is actually doing.
Certainly I'd always assumed that the finalizer of an object would run eventually, even if it was sometime long after the object was eligible for garbage collection.
Any comments/docs to the contrary are welcome. I've not used finalizers heavily so I've not had any problem with them and your comment was at odds with what I thought to be the case. If I'm simplifying something and there is something I'm missing, please let me know.
Cheers Kerr
-- Kerr Rainey - [EMAIL PROTECTED] - http://www.rokera.com
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
