Re: JavaMemoryModel: volatile arrays

From: David F. Bacon (dfb@watson.ibm.com)
Date: Thu Dec 02 1999 - 07:38:57 EST


so the change you are suggesting is that "volatile", when applied to arrays,
means that the elements of the array are volatile, in addition to the reference
to the array?

if that's what you're suggesting, i think it's problematic. it means that
volatile has a different meaning for array and object references. the anomaly
is exposed most clearly if i write

    volatile int[] data = new int[10];
    int[] d = data;

so now array operations via the "d" reference are not volatile, but the
operations via the "data" reference are volatile, even though they refer to the
same "variables" (in the JLS Ch 17 sense). in java as it stands, a variable is
either volatile or not. making volatility depend on the path used to access
the variable seems both inelegant and confusing.

david
-------------------------------
JavaMemoryModel mailing list - http://www.cs.umd.edu/~pugh/java/memoryModel



This archive was generated by hypermail 2b29 : Thu Oct 13 2005 - 07:00:23 EDT