[I don't know if this is off-topic, so please forgive me if it is.]
I am trying to employ copy-on-write with a Map in a project to avoid
synchronized access to it. As the program runs, the Map grows as new
mappings are added, but they are added in less frequency as time goes on
until eventually no more mappings get added. There is logic that needs to
get a value for a particular key from the Map and add a new mapping if the
key isn't present. I don't see how to accomplish that logic in a
thread-safe manner without avoiding the double-checked locking idiom or some
other concurrency error. Oh, and should the reference to the Map be made
volatile? From my understanding, it should be. I don't understand why the
reference to the internal array in
EDU.oswego.cs.dl.util.concurrent.CopyOnWriteArrayList is not marked
volatile.
~ David Smiley
MITRE
-------------------------------
JavaMemoryModel mailing list - http://www.cs.umd.edu/~pugh/java/memoryModel
This archive was generated by hypermail 2b29 : Thu Oct 13 2005 - 07:00:36 EDT