X-Received: by 2002:ac8:3ac4:: with SMTP id x62mr1966718qte.28.1554486816561; Fri, 05 Apr 2019 10:53:36 -0700 (PDT) X-Received: by 2002:a25:542:: with SMTP id 63mr12290762ybf.331.1554486816288; Fri, 05 Apr 2019 10:53:36 -0700 (PDT) Path: csiph.com!xmission!news.snarked.org!border2.nntp.dca1.giganews.com!nntp.giganews.com!t9no1768951qtn.0!news-out.google.com!i8ni755qtr.1!nntp.google.com!t9no1768945qtn.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.java.programmer Date: Fri, 5 Apr 2019 10:53:35 -0700 (PDT) In-Reply-To: <636ed842-3212-4955-8c81-0a48f162b6b9@googlegroups.com> Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=84.74.101.34; posting-account=UjEXBwoAAAAOk5fiB8WdHvZddFg9nJ9r NNTP-Posting-Host: 84.74.101.34 References: <636ed842-3212-4955-8c81-0a48f162b6b9@googlegroups.com> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: Subject: Re: Does this make sense? From: bursejan@gmail.com Injection-Date: Fri, 05 Apr 2019 17:53:36 +0000 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Lines: 20 Xref: csiph.com comp.lang.java.programmer:38875 I think you don't need an extra thread. Since Swing runs anyway in its own thread.=20 If you display a non-modal window, the current thread will not block. And you can perform the for(;;) loop in the main thread itself, without starting a thread. The problem is only, how does the main thread get events from the watcher and from the window? Well the same way, via interrupt(). So the main thread can detect whether it go a watcher.take() or whether it got interrupted. And it can gracefully terminate and close also whatever resources it has opened. If some tooling shows an error somewhere, submit a bug report. Lets see what they say... On Friday, April 5, 2019 at 5:39:25 PM UTC+2, Eric Douglas wrote: > On Thursday, April 4, 2019 at 8:33:50 PM UTC-4, Arne Vajh=C3=B8j wrote: