ConcurrentHashMap read while resizing
问题 I would like to know the possible scenarios that can occur when we are trying to read a ConcurrentHashMap while it is resizing. I know that during read, first attempt is always unsynchronized. In second attempt it will try to acquire lock and retry. But if it happens during resizing how would it work? Thanks 回答1: By looking at the source: A ConcurrentHashMap contains one or more segments, depending on the concurrency level. During a rehash, a segment is locked and the new table is built next