Intuitively, ConcurrentHashMap should behave like a set of mutable variables; The keys of the card are variable addresses. get(key) and put(key, value) should behave like mutable read and write.
This is not explicitly stated in the document. Nevertheless, I firmly believe that this is so. Otherwise, there will be many unexpected, amazing behaviors that undermine the application logic. I don't think Doug Lee will do this with us. Of course, someone asks him on the concurrency-interest mailing list.
Suppose it obeys volatile semantics, we can reason based on the Java memory model -
All volatile reads and writes form a single common order. This can be considered a pseudo-temporary string, where read / write are the points on it.
Volatile reading sees the immediate preceding volatile record and sees only the record. The “preceding” here corresponds to the pseudo-timeline.
The pseudo-timeline may differ from the “real” timeline. However, theoretically, volatile recording cannot be infinitely delayed on a pseudo-time line. And, by right, the two lines of time are quite close.
Therefore, we can be sure that the volatile record should become visible “very quickly” for reading.
source share