Mon Mar 27 08:27:00 GMT 2000
On Monday, March 27, 2000 at 08:05, Cedric Berger wrote:
> > How do you deal with objects that override the finalize method,
> > needing special finalization?
> Finalization must only be used for releasing resources like memory,
> syncronization objects, ... which means that its main use is for
> native methods.
There is at least one situation in unix where it is (almost) absolutely
necessary: When you need to restore a terminal's state.
If I initialize ncurses natively in some object, I need to either
have the user manually restore the terminal, or do it during
finalization. I prefer the latter because it is easy to write buggy
code that never cleans up. (But it is also easy to write code that
always cleans up - except if the program wa killed by SIGINT/SIGTERM.)
Maybe there is some other solution to this problem that I'm missing...
Oskar Liljeblad (firstname.lastname@example.org)
More information about the Java