Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!gegeweb.org!eternal-september.org!feeder.eternal-september.org!mx04.eternal-september.org!.POSTED!not-for-mail From: markspace <-@.> Newsgroups: comp.lang.java.programmer Subject: Re: Volatile happens before question Date: Tue, 17 Jan 2012 12:09:24 -0800 Organization: A noiseless patient Spider Lines: 22 Message-ID: References: <09848313-2372-4c23-8f52-fa84c612c100@u32g2000yqe.googlegroups.com> <15jRq.2104$d%2.1226@newsfe07.iad> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Tue, 17 Jan 2012 20:09:27 +0000 (UTC) Injection-Info: mx04.eternal-september.org; posting-host="XjIWM99mD7Ijfdu600oVPA"; logging-data="16221"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19uGc3QhpcFRzSNrBSW20Tp7Mj0RVJSJ7E=" User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:8.0) Gecko/20111105 Thunderbird/8.0 In-Reply-To: Cancel-Lock: sha1:B0BmP2To1/9RMBCl5OxEWWbmAZM= Xref: x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:11424 On 1/17/2012 11:06 AM, Daniel Pitts wrote: > On 1/17/12 10:41 AM, markspace wrote: >> He's reading "b" first. He stores b in bStore, and then checks "a". > He is reading b first. Right. "b" is not volatile. So we can't say anything at all about the value of "b". Full stop. > If b=1, that means a MUST be true. No, if b = 1, it could just be a random value made up by the CPU. Check Java Concurrency in Practice. "Programs with data races have no useful defined semantics." That's exactly what Brian Goetz says, and this is what he's talking about. Reads and writes no longer work if you obviate synchronization.