Home > Back-end >  Why are there no ConcurrentTreeMap implementation?
Why are there no ConcurrentTreeMap implementation?

Time:03-25

Is also a red-black tree, why there are concurrent hashmap security class, treeMap is no, because of the high tree no hash CARDS?

CodePudding user response:

Don't know a hashmap with more? After all the hash and linkedHashMap.

CodePudding user response:

HashMap based on hash table implementation, TreeMap based on red-black tree implementation,
HashMap does not support thread synchronization, is thread safe, any time that you can have multiple threads at the same time to write a HashMap, could lead to inconsistent data, if need to be synchronized, can use the Collections and synchronizedMap method makes a HashMap with synchronous ability, or use a ConcurrentHashMap,

CodePudding user response:

Name
refer to the second floor injured brain response:
HashMap based on hash table implementation, TreeMap based on red-black tree implementation,
HashMap does not support thread synchronization, is thread safe, any time that you can have multiple threads at the same time to write a HashMap, may lead to inconsistent data, if need to be synchronized, can use the Collections and synchronizedMap method makes a HashMap with synchronous ability, or use a ConcurrentHashMap,

HashMap with red and black tree, in addition, I also don't need you to popular science hashMap class thread safe extension
  • Related