Java Concurrency Interview

synchronized, monitors, wait and notify question 34 of 180 senior

What is lock striping, and when does it stop helping?

One lock over a whole map serialises every operation. Striping guards partition N with lock N, so threads touching different partitions proceed in parallel. ConcurrentHashMap before Java 8 used 16 segments this way; since Java 8 it locks the individual bin instead, which is striping taken to its limit.

It stops helping in three situations, and naming them is the senior part of the answer. When access is skewed and one partition is hot, you are back to a single lock. When an operation needs a global view (size(), resizing, a range query), you must take every stripe, which is more expensive than one lock would have been. And when stripes share a cache line, false sharing turns independent locks into contention at the hardware level.

locks performance scalability

Quiz yourself on synchronized, monitors, wait and notify Suggest a correction