Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!eternal-september.org!feeder.eternal-september.org!.POSTED!not-for-mail From: markspace <-@.> Newsgroups: comp.lang.java.programmer Subject: Re: Java thread Date: Sat, 10 Sep 2011 21:34:39 -0700 Organization: A noiseless patient Spider Lines: 15 Message-ID: References: <128ea2e0-7a2e-4c86-9507-8e15a0b892b9@p25g2000pri.googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Sun, 11 Sep 2011 04:34:56 +0000 (UTC) Injection-Info: mx04.eternal-september.org; posting-host="XjIWM99mD7Ijfdu600oVPA"; logging-data="16909"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18wFMTN+S65DfutNy41TbRRr72ILxwKiHA=" User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:6.0.2) Gecko/20110902 Thunderbird/6.0.2 In-Reply-To: <128ea2e0-7a2e-4c86-9507-8e15a0b892b9@p25g2000pri.googlegroups.com> Cancel-Lock: sha1:hnaIDO0hL21d4+kjBlVb6Q8rboE= Xref: x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:7778 On 9/10/2011 9:03 PM, Jack wrote: > For Java thread, how to ensure that wait() does not miss notify()? > Otherwise the thread will hang and can not shut down. You can't. The timing involved can always be such that notify is called when the thread is not waiting. I believe you're using the wrong mechanism if you're worried about thread shutdown. Look into Thread.interrupt() instead.