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


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

Re: How do I automatically cleanly terminate a thread?

Path csiph.com!news.swapon.de!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From Martin Gregorie <martin@address-in-sig.invalid>
Newsgroups comp.lang.java.programmer
Subject Re: How do I automatically cleanly terminate a thread?
Date Mon, 17 Jul 2017 18:16:04 -0000 (UTC)
Organization A noiseless patient Spider
Lines 26
Message-ID <okiut4$44e$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
Content-Transfer-Encoding 8bit
Injection-Date Mon, 17 Jul 2017 18:16:04 -0000 (UTC)
Injection-Info mx02.eternal-september.org; posting-host="6728d4055d19f32300e747934872bde7"; logging-data="4238"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+7ammqKH2CSlFJIavCaVML8oVufnIOVfI="
User-Agent Pan/0.141 (Tarzan's Death; 168b179 git.gnome.org/pan2)
Cancel-Lock sha1:NgpgAIJ373C6fCE6kmQwhM6Rxa8=
Xref csiph.com comp.lang.java.programmer:36963

Show key headers only | View raw


On Mon, 17 Jul 2017 10:05:07 -0700, Eric Douglas wrote:

> 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.
>
IIRC you said that the reference to the thread is lost so it can't be 
shut down. Is there no way this could be preserved, maybe with an 
extended JButton that triggers the thread by calling a method in your 
Model? 

This would mean you could keep the thread reference so that your shutdown 
code can terminate it cleanly. 

Alternatively, an extended JButton might pass the thread a reference to a 
variable used by shutdown code to tell the thread to terminate.



-- 
martin@   | Martin Gregorie
gregorie. | Essex, UK
org       |

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