Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #36964

Re: How do I automatically cleanly terminate a thread?

Path csiph.com!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From Knute Johnson <nospam@rabbitbrush.frazmtn.com>
Newsgroups comp.lang.java.programmer
Subject Re: How do I automatically cleanly terminate a thread?
Date Mon, 17 Jul 2017 13:29:23 -0500
Organization A noiseless patient Spider
Lines 18
Message-ID <okiveo$846$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> <okiprf$k64$1@dont-email.me> <446909b0-32bf-4c2e-b81c-9e55832a2c8f@googlegroups.com>
Mime-Version 1.0
Content-Type text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding 7bit
Injection-Date Mon, 17 Jul 2017 18:25:30 -0000 (UTC)
Injection-Info mx02.eternal-september.org; posting-host="ed19dde6d4eefd924907c4d9bf7f7ff0"; logging-data="8326"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/TX6pYXGQ7810ZTvpDUGO6"
User-Agent Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1
In-Reply-To <446909b0-32bf-4c2e-b81c-9e55832a2c8f@googlegroups.com>
Content-Language en-US
Cancel-Lock sha1:RKHOppr+lxhyQR4ne4iimxT6K8E=
Xref csiph.com comp.lang.java.programmer:36964

Show key headers only | View raw


On 7/17/2017 12:05, Eric Douglas wrote:
> On Monday, July 17, 2017 at 12:54:06 PM UTC-4, Knute Johnson wrote:
>>
>> Why don't you interrupt the thread as part of the shutdown process and
>> then it will print your message in the catch section.
>>
> 
> That's what I was trying to do but I created this from a GUI object.  Normally the JVM terminates when the last GUI object is destroyed but this thread stays active (if it's not a daemon).  I was wondering if there's a way to let it know it can interrupt it's own thread rather than having to remember to call a close method to interrupt it's thread from the windowClosing method.
> 

If I want to shutdown a thread before the GUI terminates I usually 
create a stop method that terminates all the threads that need to be 
stopped before the GUI.  If they are threads that can just be killed, I 
make them daemon threads and ignore them.

-- 

Knute Johnson

Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


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