|
From: Martin C. <mus...@us...> - 2003-02-04 15:50:26
|
On Tue, 2003-02-04 at 10:36, Bas Cancrinus wrote: > Bill Horsman wrote: > > We have not found any robust way of determining when the application has > > ended. Any suggestions are welcome. > > Runtime.addShutdownHook() is the key (JRE 1.3+). Shutdown hooks are > always executed by the VM, no matter how it exits. The only drawback is > an extra permission when the app is forked: > > permission java.lang.RuntimePermission "shutdownHooks"; > > According to the discussions at the JDC it is never guaranteed that the > VM executes finalize(), whereas it is for shutdown hooks - I confirm > this by my own practice. A few notes: 1- Not all VM implementations apparently support the shutdownHook properly. I do not have any solid evidence to this available, but this is what I know I've read in places before. 2- http://java.sun.com/j2se/1.4.1/docs/guide/lang/hook-design.html Is a good place to look at. 3- Perhaps for versions -1.3 to use this Runtime.runFinalizersOnExit Martin |