Java Concurrenthashmap Analysis

Source: Internet
Author: User

Concurrenthashmap is the thread-safe version of HashMap, and it is worth mentioning that Concurrenthashmap does not use a lock to protect the entire hash area, but instead uses 16 locks, distinguishes the hash into 16 buckets, and each lock controls a bucket, That is, lock segments, which can be more granular lock objects, so the maximum provides 16 concurrent read and write, to improve throughput.


But this technology also brings bad places, such as some methods need to scan the hash area, such as the size () method or the Containsvalue () method, so that the child will use multiple locks instead of a lock to achieve, and when the need for more locks, there is a need for some technology, Lock in order to avoid deadlocks.

Original: http://blog.csdn.net/hongchangfirst/article/details/39667989

Author: Hongchangfirst

Hongchangfirst's homepage: http://blog.csdn.net/hongchangfirst



Java Concurrenthashmap Analysis

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.