just had a look at class CopyOnWriteArrayList and I wondered why its get(...) method doesn't need any synchronization. The add(...) and set(...) methods change the underlying array in a mutex block using ReentrantLock. But get(...) just returns the raw underlying array without any synchronisation. Okay, the underlying array is declared volatile:
private volatile transient Object[] array;
But I don't see how using volatile makes any synchronisation redundant. It only prevents the reference stored in array from being cached by the compiler. If I understood why synchronisation is not needed here I could write my code with a little less lock contention than before ...
Thanks, Oliver