1

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.

2
  • Have you profiled your code and found this to be a bottleneck in practice? If not, this is premature optimization and probably more trouble than it's worth. Commented May 28, 2013 at 5:45
  • How complex is the write operation? What are the array elements, integers or an object with complex, amybe blocking, write methods? Commented May 28, 2013 at 6:07

1 Answer 1

3

You can use an AtomicXxxArray where each element can be atomically updated with appropriate visibility guarantees:

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.