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: Volatile happens before question Date: Tue, 17 Jan 2012 10:41:41 -0800 Organization: A noiseless patient Spider Lines: 16 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 18:41:44 +0000 (UTC) Injection-Info: mx04.eternal-september.org; posting-host="XjIWM99mD7Ijfdu600oVPA"; logging-data="13787"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+uy2SOt/2apMjmM1bluN8LNpmE8Wagivk=" User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:8.0) Gecko/20111105 Thunderbird/8.0 In-Reply-To: <15jRq.2104$d%2.1226@newsfe07.iad> Cancel-Lock: sha1:9lpPUZBXavISMyn3ykGtbIX52gc= Xref: x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:11420 On 1/17/2012 10:28 AM, Daniel Pitts wrote: > a was volatile, so it does cause the happens-before relationships with > the reads/writes of b. I messed up again, but I'm still right. :) He's reading "b" first. He stores b in bStore, and then checks "a". Thread 2 int bStore = b; <--- DON'T MISS THIS BIT if (!a) { System.out.println("The value of b is " + bStore); }