HomeAboutMeBlogGuest
© 2025 Sejin Cha. All rights reserved.
Built with Next.js, deployed on Vercel
📝
남득윤 학습 저장소
/
자바 콜렉션
자바 콜렉션
/
🧵
HashMap & ConcurrentHashMap
🧵

HashMap & ConcurrentHashMap

 
notion image
 
 
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 unlike HashMap, this class does not allow null to be used as a key or value. - 성능상 Issue 때문에 제한함