Article View: borland.public.jbuilder.java.api
Article #3441Re: runFinalizersOnExit() hangs my program when I exit()
From: Leo Breebaart
Date: Wed, 14 Jan 1998 00:00
Date: Wed, 14 Jan 1998 00:00
49 lines
2401 bytes
2401 bytes
Nikolaos Giannopoulos wrote: > "[...] (Using "runFinalizersOnExit" is generally ill-advised and deadlock-prone anyway.)" I am beginning to understand and appreciate that now. > If you need to use System.exit() to terminate a client VM, to ensure > that remote references held in that VM are cleaned up in a more timely fashion, you > should make sure that there are no remote references still reachable (explicitly > null any local references to them unreachable from running threads), and then it helps > to do something like this before exiting: > > System.gc(); > System.runFinalization(); This works, but there are two problems with it, one esthetical, one practical. Esthetical problem: the whole beauty of something like 'runFinalizersOnExit()' is that I *don't* have to worry myself about when to call my Objects' cleanup methods. If I have to explicitly nullify all my references just so the VM will now it's safe to clean the Object up when I tell it to, I might as well just call my cleanup routines myself at the same time. I'm losing virtally everything I wanted to achieve by using this construct in the first place. Practical problem: if in my program I choose File|Exit, I get to handle the event, and I can there add stuff like those System calls. But if I click on my window's close box, the darn thing gets automatically closed out of my control, and I still have the same problem. Does anybody reading this know how I can tell my program I want to handle the close box clicked event as well? Or alternatively, how to disable or remove the close box (against Interface guidelines, undoubtedly, but it would be a temporary measue until JDK gets its finalizer stuff right)? -- Leo Breebaart <leo@lspace.org>
Technical Details
Message-ID:
<34BCBBC6.271FDFA1@lspace.org>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailReferences:
<34BB79E8.C105066A@lspace.org> <34BBB748.94228598@borland.com> <01bd20d1$3dec6c40$0164cdcd@solmar>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 1089d0,23d0b465eda3bbde X-Google-Attributes: gid1089d0,public From: Leo Breebaart <leo@lspace.org> Subject: Re: runFinalizersOnExit() hangs my program when I exit() Date: 1998/01/14 Message-ID: <34BCBBC6.271FDFA1@lspace.org> X-Deja-AN: 315847007 Content-Transfer-Encoding: 7bit References: <34BB79E8.C105066A@lspace.org> <34BBB748.94228598@borland.com> <01bd20d1$3dec6c40$0164cdcd@solmar> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Organization: L-Space Newsgroups: borland.public.jbuilder.java.api