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: Wed, 18 Jan 2012 16:12:21 -0800 Organization: A noiseless patient Spider Lines: 21 Message-ID: References: <09848313-2372-4c23-8f52-fa84c612c100@u32g2000yqe.googlegroups.com> <1pi7kea3zdo0b.1ixhuq3p9ybbu$.dlg@40tude.net> <60dddbf9-3686-4824-a918-64a59faba177@a8g2000vba.googlegroups.com> <726da9ce-57f4-4136-b50b-56a032aca196@f1g2000yqi.googlegroups.com> <652cb878-fb2f-4361-8f70-61bc493cebf6@r16g2000yqi.googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Thu, 19 Jan 2012 00:12:23 +0000 (UTC) Injection-Info: mx04.eternal-september.org; posting-host="XjIWM99mD7Ijfdu600oVPA"; logging-data="25215"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19b0Pj2EUvUmaMMFWjFuVQFr2GXQo9k/C0=" User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:8.0) Gecko/20111105 Thunderbird/8.0 In-Reply-To: Cancel-Lock: sha1:3EtTtfEQEsqVJ7NQ8Otcg+cith4= Xref: x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:11481 On 1/18/2012 3:00 PM, Knute Johnson wrote: > On 1/18/2012 1:16 PM, markspace wrote: >> That's what I was thinking. With folks like Brian Goetz and Bartosz >> saying the system can simply invent values, it's hard to analyze the >> resulting code for any kind of deterministic behavior. Esp. because Java >> is a step away from the machine, and I don't know exactly what sort of >> operations are going to be executed. > > I know that the JLS says that variables can have values out of thin air > but Goetz says on page 36 "When a thread reads a variable without > synchronization, it may see a stale value, but at least it sees a value > that was actually placed there by some thread rather then some random > value. This safety guarantee is called out-of-thin-air safety." That's a good find. I can't reconcile that statement with other things I'm seeing. Since real world hardware seems to be able to produce values out of thin air, I don't see how Java could prevent this. It seems that one or the other statement is incorrect.