Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.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: Fri, 20 Jan 2012 08:56:09 -0800 Organization: A noiseless patient Spider Lines: 25 Message-ID: References: <09848313-2372-4c23-8f52-fa84c612c100@u32g2000yqe.googlegroups.com> <726da9ce-57f4-4136-b50b-56a032aca196@f1g2000yqi.googlegroups.com> <652cb878-fb2f-4361-8f70-61bc493cebf6@r16g2000yqi.googlegroups.com> <6280ea10-c656-40fa-ba3d-50f24d471978@j15g2000yqb.googlegroups.com> <6b44805b-ff63-41ba-8060-cbd92164f9d6@o9g2000yqa.googlegroups.com> <240ac224-9713-4931-89f6-aeb7578aee09@m11g2000yqe.googlegroups.com> <5ff9ba43-a357-4c0b-9c26-0a90242884d5@m11g2000yqe.googlegroups.com> <626c6bb6-103f-4b89-8484-316641c0476c@18g2000yqe.googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Fri, 20 Jan 2012 16:56:12 +0000 (UTC) Injection-Info: mx04.eternal-september.org; posting-host="XjIWM99mD7Ijfdu600oVPA"; logging-data="5321"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/qRCQhQCvsHw+lROnAmMAVr3EDnuvGyR0=" User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:8.0) Gecko/20111105 Thunderbird/8.0 In-Reply-To: <626c6bb6-103f-4b89-8484-316641c0476c@18g2000yqe.googlegroups.com> Cancel-Lock: sha1:xInLacH20zzpp+IAr4SrMlYqJ0Y= Xref: x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:11524 On 1/20/2012 3:23 AM, raphfrk@gmail.com wrote: > The issue is that a read of the old value doesn't guarantee that no > update has happened. ... > Even though WA happens after RB in the synchronization ordering, > there is no relationship between R-read and W-write. The reason is > that WA and RB have no happens-before relationship. I don't think this is quite correct. No update is in progress in your trace. What I think they're talking about is causality, or the idea that map.get() might see a write from the future. That is, a write from the map.put(). I don't see anywhere in the JLS where it says that reads can't be reordered across this type memory barrier. I'll have to dig out JCIP since at this point I think trying to read the math heavy sections of the JLS have defeated me. The read from the future thing kinda makes sense, since I don't recall anything that prevents it. Maybe there is though... Note I already mentioned this about 4 posts ago... ;-)