Path: csiph.com!usenet.pasdenom.info!gegeweb.org!eternal-september.org!feeder.eternal-september.org!mx04.eternal-september.org!.POSTED!not-for-mail From: Eric Sosman Newsgroups: comp.lang.java.help Subject: Re: Please help me kill this java thread..... code example Date: Thu, 15 Nov 2012 13:33:17 -0500 Organization: A noiseless patient Spider Lines: 46 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Thu, 15 Nov 2012 18:33:17 +0000 (UTC) Injection-Info: mx04.eternal-september.org; posting-host="ffb8f7085759b339c1002252b48331a4"; logging-data="30429"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+Ng7q4zgMyUx9+/xQMxRgx" User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:16.0) Gecko/20121026 Thunderbird/16.0.2 In-Reply-To: Cancel-Lock: sha1:cgypwqL7bzKgDncsuVkoX/QBDEI= Xref: csiph.com comp.lang.java.help:2265 On 11/15/2012 1:16 PM, kedward777@gmail.com wrote: > Thank you for your help! Sorry, I did have many more printouts to stdout, but stripped them to make it easier to read.... It is interesting that you said the System.exit should should down everything, now I am stumped...but here are my responses: > >> 1) The shutdown() method is never called. You haven't shown >> us any of the arrangements you've made to have it called, >> so we can't tell whether they're correct (or even whether >> they exist). Try `System.out.println("Kilroy was here");' >> at the start of shutdown(), just to find out whether you >> do or do not ever get there. >> 2) A security manager forbids exit() from doing anything. >> If this happens a SecurityException will be thrown, and >> that might (or might not) be what stops the GUI. Perhaps >> your habit of catching and ignoring exceptions has blinded >> you to what's going on here. > > I am sure shutdown is being called, because I can see that the GUI does shutdown/closes. There are many things that might stop the GUI, so the fact that it vanished does not prove shutdown() was called. Have you tried the suggested println()? >> 3) You're wrong: The worker thread does in fact stop. You've >> not explained why you think it's still running, so we can't >> tell whether your conclusion is correct. > > I do not believe the worker thread is stopping because AFTER I click on the shutdown button, I then see the GUI shutdown/close, BUT I still see the netbeans JMV stdout window say the jvm is running still, AND I can perform ONE LAST scan, AND THEN I see the netbean jvm window close, and the scanner beam is then silent. Okay: I've come up with a fourth guess. Perhaps exit() has in fact been called (and allowed), and the JVM is in the process of shutting down. But perhaps shutdown cannot complete while the scanner code holds a lock or other resource (JNI?) that the JVM's shutdown needs before shutdown can complete. Firing the scanner one last time might jar things loose. (Remember: This is still just a guess.) The scanner code (in another thread you called it "the motorola sample program") is not known to me, so I can't say what it might be hanging on to. Knute Johnson's suggestion of interrupting the thread might work, if the code is well-behaved (and doesn't, for example, just catch and ignore exceptions); I'd suggest giving it a try. If that doesn't help -- well, you say you're using NetBeans, which means you have a debugger available; have you used it to find out what the threads are doing instead of exiting? -- Eric Sosman esosman@comcast-dot-net.invalid