[concurrency-interest] ReadMostlyVector vs CopyOnWriteArrayList

Markus Krainz ldm at gmx.at
Wed Feb 13 07:27:04 EST 2013


Hi,

I have a question regarding ReadMostlyVector from the jsr166e package. I 
had a look at the sourcecode and it uses StampedLock, for which some 
impressive benchmarks results have been reported on this. For it's use 
cases it seems pretty similar to CopyOnWriteArrayList. There are some 
subtile differences from the API docs. The CopyOnWriteArrayList iterator 
does not reflecting changes, while the ReadMostlyVector will reflect 
them on a best effort basis (if snapshotIterator() is not used). 
CopyOnWriteArrayList's cow might have higher memory overhead. When 
should we use ReadMostlyVector in preference to CopyOnWriteArrayList?

Thanks and best regards,
Markus Krainz

[1]: 
http://gee.cs.oswego.edu/dl/jsr166/dist/jsr166edocs/jsr166e/extra/ReadMostlyVector.html
[2]: 
http://docs.oracle.com/javase/7/docs/api/java/util/concurrent/CopyOnWriteArrayList.html


More information about the Concurrency-interest mailing list