Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!news.albasani.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 keyword Date: Mon, 12 Dec 2011 10:00:09 -0800 Organization: A noiseless patient Spider Lines: 19 Message-ID: References: <41fa02ff-3f20-41bc-90d9-c3f7d3651fbf@n6g2000vbg.googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Mon, 12 Dec 2011 18:00:12 +0000 (UTC) Injection-Info: mx04.eternal-september.org; posting-host="XjIWM99mD7Ijfdu600oVPA"; logging-data="2332"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18dLr9rtsdz8hHVWDlrWpg80QJwW2WxsDY=" User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:8.0) Gecko/20111105 Thunderbird/8.0 In-Reply-To: <41fa02ff-3f20-41bc-90d9-c3f7d3651fbf@n6g2000vbg.googlegroups.com> Cancel-Lock: sha1:DHGJx2fusV6SnERGvGx9HhtQ+Eo= Xref: x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:10674 On 12/12/2011 4:51 AM, raphfrk@gmail.com wrote: > Effectively, does the CPU lock the entire 64-bits for the long when > doing the write update, and so other threads either seen the updated > value or the old value? I don't like the word "lock" here because it implies something that probably isn't happening. I think that volatile, even for long and double, is specified to be much lighter weight than a lock. The spec that Lew referred to says they are "atomic" and doesn't mention "lock." I think of them that way, myself, in addition to "light weight" as opposed to the more heavy actual lock. volatile long === light weight & atomic. (=== here meant to mean "defined to be.")