threads+CNI+SIGINT

Cedric Berger cedric@wireless-networks.com
Mon Mar 27 08:40:00 GMT 2000


I looks like that you'll have to wait for JDK1.3 that implements the
mechanism you want in Runtime.addShutdownHook.

see at:
http://java.sun.com/products/jdk/1.3/docs/api/java/lang/Runtime.html#addShutdownHook (java.lang.Thread)

Cedric




Oskar Liljeblad wrote:

> 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 (osk@hem.passagen.se)


More information about the Java mailing list