Interview process (1)

Why not take notes and learn by doing? ?
Too slow, maybe not enough time! Just understand the principle!

1. ConcurrentHashMap principle

https://blog.csdn.net/qq_33591903/article/details/106634270

2. The difference between HashMap, HashTable, ConcurrentHashMap and TreeMap

1. HashMap:
implements the Map interface, allowing one NULL key and multiple NULL values, and is non-thread safe. When multiple NULL values ​​appear, Thread operations involve data synchronization issues. You can obtain a thread-safe Map from HashMap by using the Collections.synchronizedMap(Map<K,V> m) method, but this synchronized will lock the entire HashMap, which means it will be more efficient. Low,

2. HashTable:
also implements the Map interface, which existed before jdk1.1, but does not allow NULL keys and NULL values< /span>synchronized to lock the entire Hash table to achieve thread safety. That is, the entire table is locked each time so that the thread can occupy it exclusively. So HashTable is suitable for single thread. . It uses HashTable is a thread-safe class, slower than HashMap because it is synchronous.

3. ConcurrentHashMap:
is introduced after jdk1.5 ࿰

Guess you like

Origin blog.csdn.net/qq_44787816/article/details/129050170