Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!news.albasani.net!eternal-september.org!feeder.eternal-september.org!.POSTED!not-for-mail From: markspace <-@.> Newsgroups: comp.lang.java.programmer Subject: Re: AtomicReferenceArray writes and visibility Date: Thu, 31 Mar 2011 21:58:20 -0700 Organization: A noiseless patient Spider Lines: 18 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Fri, 1 Apr 2011 04:58:21 +0000 (UTC) Injection-Info: mx02.eternal-september.org; posting-host="sJe4u9VRc4chc5yBzxahWw"; logging-data="25961"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/iA7yW+jgUyaDAZImswBsMvrDQO5HZ6JA=" User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.15) Gecko/20110303 Thunderbird/3.1.9 In-Reply-To: Cancel-Lock: sha1:LDkG74PYstg4DG3gQfvuLTl9d1Y= Xref: x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:2690 On 3/31/2011 9:54 PM, Peter Duniho wrote: > On 3/31/11 9:22 PM, markspace wrote: >> [...] >> Read the source code for the AtomicReferenceArray. set() doesn't use any >> synchronization. It calls sun.misc.Unsafe#putObjectVolatile(). I don't >> see how that's going to create a happens-before. > > "volatile" creates the happens-before. All writes before a volatile > write in the same thread must be visible in a given thread after a > volatile read in the same thread from the same location. I didn't notice the keyword volatile there. Did I miss it? Regardless, the lack of any guarantees in the docs of AtomicReferenceArray would kill it for me. You can't be sure how the implementation will change over time.