Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!eternal-september.org!feeder.eternal-september.org!mx04.eternal-september.org!.POSTED!not-for-mail From: markspace <-@.> Newsgroups: comp.lang.java.programmer Subject: Re: Question whether a problem with race conditions exists in this case Date: Wed, 14 Dec 2011 15:26:23 -0800 Organization: A noiseless patient Spider Lines: 14 Message-ID: References: <8bbbbee3-adcc-4f28-aff5-2e230b047401@u6g2000vbg.googlegroups.com> <31419376.376.1323889493017.JavaMail.geo-discussion-forums@prmw6> <1e0613c1-9248-4f1d-a5e1-65f08aa31c0f@y18g2000yqy.googlegroups.com> <2d12332c-63f4-46ee-a06d-f949807887bb@m10g2000vbc.googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Wed, 14 Dec 2011 23:26:25 +0000 (UTC) Injection-Info: mx04.eternal-september.org; posting-host="XjIWM99mD7Ijfdu600oVPA"; logging-data="11431"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19k3Lgny5W5lzm6NvCgWqR8xSAHv0gQwuI=" User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:8.0) Gecko/20111105 Thunderbird/8.0 In-Reply-To: <2d12332c-63f4-46ee-a06d-f949807887bb@m10g2000vbc.googlegroups.com> Cancel-Lock: sha1:WexKioPB97plQJxe53mwjjodFZE= Xref: x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:10757 On 12/14/2011 2:50 PM, Saxo wrote: > On Dec 14, 11:44 pm, Eric Sosman wrote: >> The instance field gets changed in the setNewValue() call. >> The original value is only there, as far as I can see, to cough >> up a "false" until it's replaced. > > Yes, right :-). That's not really good enough. If the instance value exists for any time, then there's a chance that a thread will come in before you have a chance to use it. It's a big trap for anyone who didn't design the code. My way was much more clear and also bullet proof.