java.util.concurrent.ConcurrentHashMap
uses a Segment
array as Mutex
and Segment Object
is small than cache line.
Does this lead to false sharing?
While the Segments are small, this is not where the multi-threading support happens. It extends ReentrantLock which uses a Sync object which extends AbstractQueuedSchronizer which uses Node objects. All these objects would be copied as a group and are likely to be spaced out reasonably well. This would depend on the implementation of the GC as to how this is done, but for Hotspot it is copied in reverse order of discovery (i.e. a deep copy) so it is likely this will be fine.