Path: csiph.com!optima2.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!us.feeder.erje.net!news2.arglkargh.de!news.swapon.de!eternal-september.org!feeder.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail From: Eric Sosman Newsgroups: comp.lang.java.programmer Subject: Re: javax.swing.Timer blocking program termination Date: Tue, 14 Jul 2015 10:53:35 -0400 Organization: A noiseless patient Spider Lines: 17 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Tue, 14 Jul 2015 14:52:12 +0000 (UTC) Injection-Info: mx02.eternal-september.org; posting-host="858a9d65d95f4ea4d355bd116aa2cdbf"; logging-data="11172"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX180hQsWRlmSd8wVKdPaNWlf" User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.0.1 In-Reply-To: Cancel-Lock: sha1:8PJtIgALm9RydKUOG5XxwX532/U= Xref: csiph.com comp.lang.java.programmer:32009 On 7/14/2015 10:39 AM, e.d.programmer@gmail.com wrote: > [...] > Closing a window should never terminate a JVM unless you flag it as EXIT_ON_CLOSE which is not recommended. You may want a timer to be able to do some cleanup after the window closes, so if the timer is running a process which doesn't need to finish if the window closes you want to manually stop it in the window close event process. Could you elaborate on "not recommended?" For my own applications, EXIT_ON_CLOSE is the option I use most frequently. The next is DO_NOTHING_ON_CLOSE with a WindowAdapter for window-closing events; both stratagems seem unobjectionable to me. > A method to stop all timers could be useful. It appears you currently have to store a reference to any timers you create if you need to be able to stop them. A method to stop all timers sounds about as useful as a method to stop all threads -- that is to say, more perilous than useful. -- esosman@comcast-dot-net.invalid "Don't be afraid of work. Make work afraid of you." -- TLM