Hashtable 线程安全的,但效率低 内部有上锁的控制 synchronized Hashmap 线程不安全的,但效率高 ConcurrentHashMap 兼顾了线程安全和效率的问题 分析:HashTable锁了整段数据(用户操作是不同的数据段,依然需要等待) 解决方案:把数据分段,执行分段锁(分离锁... HashMap、TreeMap、L
Hashtable is synchronized, in contrast to HashMap. This gives us the reason that HashMap should be used if it is thread-safe, since Hashtable has overhead for synchronization. 2. HashMap If key of the HashMap is self-defined objects, then equals() and hashCode() contract need to be f...
None of these implementation are synchronized. That is if multiple threads access a set concurrently, and at least one of the threads modifies the set, it must be synchronized externally. LinkedHashSetis in some sense intermediate betweenHashSetandTreeSet. Implemented as a hash table with a link...