Concurrent Hash Map get 和 put 重叠

Concurrent Hash Map get and put overlapping

我读到 get 方法在 ConcurrentHashMap(Jdk 7 ) 中是完全并发的,因此它可以与所有更新操作重叠。如果两个线程 运行 put(Key,V)Get (Key) 同时存在,如果 Key 不存在会发生什么情况?

根据JDK7 Javadoc

Retrievals reflect the results of the most recently completed update operations holding upon their onset.

这意味着 get() 将 return null 如果它在 put() 完成之前被调用。

您问题的简短回答是:put() 将 return null