Reputation: 45
Which Java Concurrent collection provide Array element level locking or atomic updation of Array elements. I do not want to lock entire array. there is 99% read operations and only 1% write operations only.
Locking while writing in array will block may other threads which even might not be looking at the same element which is being updated by blocking thread.
Upvotes: 1
Views: 117
Reputation: 328598
You can use an AtomicXxxArray
where each element can be atomically updated with appropriate visibility guarantees:
Upvotes: 3