Originally posted by Paula Davis:
(I hope I picked the right forum for this question...)
I am wanting for an object (of a class I am writing) to be able to save the values of its variables to a file before it goes away, regardless of whether the "driver" program saves anything... would there be any drawback to doing this in the object's finalize() method?
use the [CODE] tags - it makes it much easier for people to help you.
"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. Nor does the language specify which thread will invoke the finalizer for any given object. If an uncaught exception is thrown during the finalization, the exception is ignored and finalization of that object terminates."
you don't know when finalize() will be called, if at all.
use the
However, it is also a question for general/future reference, because this is the first time that I have had occasion to want to use finalize().
Thanks.
Paula
Is it a fact that "finalize()" may not be called at all, or was that hyperbole?
use the [CODE] tags - it makes it much easier for people to help you.
"I'm not back." - Bill Harding, Twister
Consider Paul's rocket mass heater. |