Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #36962
| From | Eric Sosman <esosman@comcast-dot-net.invalid> |
|---|---|
| Newsgroups | comp.lang.java.programmer |
| Subject | Re: How do I automatically cleanly terminate a thread? |
| Date | 2017-07-17 13:05 -0400 |
| Organization | A noiseless patient Spider |
| Message-ID | <okiqgv$mhv$1@dont-email.me> (permalink) |
| References | <bca988ab-7993-4b11-866a-bc3ab62e8988@googlegroups.com> <okikph$20d$1@dont-email.me> <23395a95-7741-4c12-bb16-bb50341df864@googlegroups.com> |
On 7/17/2017 12:03 PM, Eric Douglas wrote:
> On Monday, July 17, 2017 at 11:27:46 AM UTC-4, Eric Sosman wrote:
>> If all you need is that the thread goes away in order to allow the
>> JVM to terminate, it may be simplest to make it a daemon: Call its
>> setDaemon(true) method before calling start(). The JVM assumes that
>> it's all right to clobber daemon threads when shutting down, the idea
>> being that if the asynchronous shutdown causes corruption it won't
>> matter because the whole Java environment is about to disappear.
>>
>
> So my main thread kicks off this process from a JButton action. I declared it a daemon thread and it did auto terminate when the last GUI object was destroyed without calling it's proper close method. That thread was sitting on the take() method and it printing something in the InterruptedException section which never printed. So if we let the JVM terminate it with the daemons can I assume that's ok on a method like this?
The JVM happily clobbers daemon threads at shutdown.
It doesn't interrupt them, it just clobbers them, axes them,
kills them, deletes them, maims them, annihilates them, gives
them the old heave-ho, and nukes the vestigial remnants.
If you want an InterruptedException, use Thread::interrupt.
--
esosman@comcast-dot-net.invalid
Twelve hundred eighty-three days to go.
Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Find similar | Unroll thread
How do I automatically cleanly terminate a thread? Eric Douglas <e.d.programmer@gmail.com> - 2017-07-17 08:06 -0700
Re: How do I automatically cleanly terminate a thread? Eric Sosman <esosman@comcast-dot-net.invalid> - 2017-07-17 11:27 -0400
Re: How do I automatically cleanly terminate a thread? Eric Douglas <e.d.programmer@gmail.com> - 2017-07-17 09:03 -0700
Re: How do I automatically cleanly terminate a thread? Knute Johnson <nospam@rabbitbrush.frazmtn.com> - 2017-07-17 11:53 -0500
Re: How do I automatically cleanly terminate a thread? Eric Douglas <e.d.programmer@gmail.com> - 2017-07-17 10:05 -0700
Re: How do I automatically cleanly terminate a thread? Martin Gregorie <martin@address-in-sig.invalid> - 2017-07-17 18:16 +0000
Re: How do I automatically cleanly terminate a thread? Eric Douglas <e.d.programmer@gmail.com> - 2017-07-17 12:18 -0700
Re: How do I automatically cleanly terminate a thread? Eric Sosman <esosman@comcast-dot-net.invalid> - 2017-07-17 16:05 -0400
Re: How do I automatically cleanly terminate a thread? Knute Johnson <nospam@rabbitbrush.frazmtn.com> - 2017-07-17 13:29 -0500
Re: How do I automatically cleanly terminate a thread? Eric Sosman <esosman@comcast-dot-net.invalid> - 2017-07-17 13:05 -0400
csiph-web