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:
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:
HashMap | ConcurrentHashMap |
---|---|
Not Thread Safe | Thread Safe |
Allows 1 null Key | Will Not allow NULL Values |
Comments
Post a Comment