Hashmap,hashtable,concurrenthashmap comparison under multi-threading (continuous update)

Source: Internet
Author: User

1.hashMap multithreading under put will cause a dead loop, mainly the transfer method will cause a dead loop when expanding.

http://blog.csdn.net/zhuqiuhui/article/details/51849692 (Specific reason)

2.hashTable, using synchornized to ensure thread safety, thread competition in the case of fierce competition, inefficient. When a thread accesses the Hashtable method, the other threads enter the polling or blocking situation.

If thread 1 is adding elements using the Put method, thread 2 cannot put elements nor get elements, so the more intense the competition the lower.

3.concurrentHashmap

Using the lock segmentation technique, it is assumed that the container fragments the data, each section is assigned a lock, and when a line Cheng locks access to one of the data segments, other data segments can be accessed.

Hashmap,hashtable,concurrenthashmap comparison under multi-threading (continuous update)

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.