[concurrency-interest] Interesting story from Dave Dice

David Holmes davidcholmes at aapt.net.au
Mon May 25 06:46:22 EDT 2009

Peter Kovacs writes:
> 1. If an operation/class/method/whatever is not declared to be
> thread-safe, you can assume it is not. Correct? (If it is declared to
> be so, you can, perhaps, be optimistic and assume it is.)
> 2. If a variable (an array in this case) is written to, the variable
> is not "effectively immutable". (Probably useless of nitpicking on the
> meaning of "effectively".)
> Is this really novel?
I think this certainly violates the principle of least surprise. If you just
want to _read_ an array from native code, then there are no specific methods
for that, you have to use these JNI methods that assume you want to write to
the array as well. Even realizing that these are potentially mutating
methods, I still find it surprising that writing back the same values that
you read is not guaranteed to be seen correctly. Looking at what actually
happens I can go "Oh I see, yes that makes sense" - but there's no way I
would have thought of that happening before-hand.

David Holmes

More information about the Concurrency-interest mailing list