[concurrency-interest] Volatile array and Wait

Chris Purcell chris.purcell.39 at gmail.com
Wed Oct 19 13:50:32 EDT 2005

> The following might work, but might not:
> x = b[22];
> if (x < 1000)
>    temp = b;
> else
>    temp = some_other_volatile;

Hmmm. Looking at this again, it's pretty unlikely that it will *ever* 
work, as it's very easy to reorder reads across ifs. We want some way 
of making the address of the volatile we are reading from unpredictably 
determined by the value we read from b[22]. That means pointer 
arithmetic. Unfortunately, the only way of doing that (that I know of) 
in Java would look like:

     x = b[22]
     temp = a_volatile_array[x % 3]

which of course needs ... an array of volatile elements! Nice catch-22.


More information about the Concurrency-interest mailing list