
Hashtable, Collections.SynchronizedMap
HashMap
- not thread-safe
Hashtable
- Thread-safe
- 메소드에 통으로 synchrnized 걸어버림
SynchronizedMap
- Thread-safe
- 내부에 하나 가지고 있는 dummy monitor 객체에 lock을 걸어버리는 방식으로 synchronized 걸어버림
ConcurrentHashMap
- Thread-safe
- 내부 테이블 (
Node<K,V>[ ] table
)에서put
,get
의 타겟이 되는Node
에만 synchronized 걸어버림
- Like
Hashtable
but unlikeHashMap
, this class does not allownull
to be used as a key or value. - 성능상 Issue 때문에 제한함