As I understand both maps are designed to work in multithreaded enviroment. But I intereted in what features they guarantee(i.e. availability, consistency).
As I understand both maps are designed to work in multithreaded enviroment. But I
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
I believe they don’t use read locks (relying on
volatilefields to ensure that reads see writes from other threads) and are internally broken down into some number of segments (based on the expected concurrency level) that entries are distributed among, each of which uses its own write lock separate from the others. That way reads never block and writes only block if they happen to need to write to the same segment at the same time. I’m no expert on it though.As far as guarantees, I’m not sure what you’re asking.
ConcurrentMapspecifies a memory consistency guarantee: