From the author of ConcurrentHashMap
himself (Doug Lea):
The main reason that nulls aren’t allowed in ConcurrentMaps
(ConcurrentHashMaps, ConcurrentSkipListMaps) is that ambiguities that
may be just barely tolerable in non-concurrent maps can’t be
accommodated. The main one is that ifmap.get(key)
returnsnull
, you
can’t detect whether the key explicitly maps tonull
vs the key isn’t
mapped. In a non-concurrent map, you can check this via
map.contains(key)
, but in a concurrent one, the map might have changed
between calls.