I need a HashMap that is accessible from multiple threads.
There are two simple options, using a normal HashMap and synchronizing on it or using a ConcurrentHashMap.
Since ConcurrentHashMap does not block on read operations it seems much better suited for my needs (almost exclusively reads, almost never updates). On the other hand, I expect very low concurrency anyway, so there should be no blocking (just the cost of managing the lock).
The Map will also be very small (under ten entries), if that makes a difference.
Compared to a regular HashMap, how much more costly are the read and write operations (I am assuming that they are)? Or is ConcurrentHashMap just always better when there might be even a moderate level of concurrent access, regardless of read/update ratio and size?