Wednesday, 5 July 2017

ConcurrentHashMap in Java

ConcurrentHashMap is concrete implementation of ConcurrentMap. Both are from java.util.concurrent package.

Functionality:

1. The functionality is similar to normal HashMap with better concurrency.
2. ConcurrentHashMap is thread safe.
3. It doesn't lock the Map while you are reading from it.
4. It doesn't lock the entire Map when writing to it, it only locks the part of the Map that is being written to, internally.

Difference between HahsMap && ConcurrentHashMap:

HashMapConcurrentHashMap
Not Thread SafeThread Safe
Allows 1 null KeyWill Not allow NULL Values

0 comments:

Post a Comment

Note: only a member of this blog may post a comment.