2 ms·
The concurrent queue code in Java has/had an array the locks were placed in. Now the problem with putting locks in arrays instead of scattering them across the
by hinkley 4y ago
The concurrent queue code in Java has/had an array the locks were placed in. Now the problem with putting locks in arrays instead of scattering them across the heap is that you get false sharing immediately. So the array is 8 or 16 times as big as it needs to be to get one lock per cache line.
- charleslmunger 4y agoThe @Contended annotation will pad the memory layout of fields to fill a cache line and avoid false sharing.