|
| <prev next> |
Re: Fixed size CopyOnWriteArrayList vs array concurrent access.: msg#00079java.jsr.166-concurrency
Your colleague has an incorrect understanding. Because the backing array is effectively immutable (not modified after publication), for readers it only needs to be locked briefly to guarantee visibility of the reference the the array. (In fact, the implementation can do even better than that, but the point is that multiple threads can iterate the list concurrently.) The cost comes when you want to modify the list. Then the list has to be copied; if modifications are frequent, this can have significant costs. (In a naive implementation, newly arriving readers may be locked out during the copy operation, but there are tricks to prevent this.) COW structures are useful when reads greatly outnumber writes or the size of the collection is small. Eugene Gordienko wrote: > Hi All, > > We use java 1.4. We have a use case: fixed size array of objects and need > concurrent access to its elements: almost even number of reads and > writes, also some iterations. The size may be less than 10 but may be more > than 100. > > So my choice was fixed size CopyOnWriteArrayList (COWAL) ... but my > collegues' argument is: when we wrie to COWAL the chunk of it is locked > while in case of array of objects we can lock just on one array element. > > What is your experience/suggestion? > > Many thanks, > Eugene > > > > > > _______________________________________________ > Concurrency-interest mailing list > Concurrency-interest@xxxxxxxxxxxxxxxxxxxx > http://altair.cs.oswego.edu/mailman/listinfo/concurrency-interest
|
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | Re: Fixed size CopyOnWriteArrayList vs array concurrent access., Tim Peierls |
|---|---|
| Previous by Thread: | Re: Fixed size CopyOnWriteArrayList vs array concurrent access., Tim Peierls |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
| News | FAQ | advertise |