I know why and when we need to use HashMap and ConcurrentHashMap in Java.
When concurrent read and write operations involved then we use
ConcurrentHashMap(Segment lock)if we want map to be threadsafe without concurrency requirement then we use Collections.synchronizedMap (Object lock)
So my question is why we still need to use Collections.synchronizedMap(new Hashmap(...) in case of point no2.
Can't we just use ConcurrentHashMap (Even though no concurrent read/writes needed)?
Even with ConcurrentHashMap, no default memory allocation will be done for all segments which is good and still we can achieve both thread safety and single/concurrent read/writes.
If my assumption is right then its like Colections.synchronizedMap need not be used any more. Not sure if this is a dumb question but after going through details thinking like why we need Colections.synchronizedMap when we have ConcurrentHashMap.