Design: A Thread-safe Hashmap



Similar Posts:


linkedin
github
slack


Name Summary
Typical methods of hashmap get, update, delete, exists, size
Avoid frequent write locking Instead of lock the whole array, lock at smaller granularity of segments
To speed up lookup of conflicts Change linked list to balanced binary search tree
Reference Link: Internal Working of HashMap in Java
Reference Link: How ConcurrentHashMap Works Internally in Java

Q: How hash function is implemented?

  1. Eventually store data of hashmap in an array
  2. Resize

Q: Use case of concurrent hashmap?

A: TODO


Q: How to avoid hashing conflict?

A: TODO


Q: Would there be write conflicts or dirty reads?

  • Lock when updating the map
  • No locking for reading values

Q: How hashmap extend the capacity? How to resize?

A: TODO


Q: How ConcurrentHashMap is implemented in popular programming languages?


Share It, If You Like It.

Leave a Reply

Your email address will not be published. Required fields are marked *