Hacker News new | ask | show | jobs
by hinkley 1218 days 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.
1 comments

The @Contended annotation will pad the memory layout of fields to fill a cache line and avoid false sharing.