False Sharing in Java
Jakob Jenkov
False sharing in Java occurs when two threads running on two different CPUs write to two different variables which happen to be stored within the same CPU cache line. When the first thread modifies one of the variables - the whole CPU cache line is invalidated in the CPU caches of the other CPU where the other thread is running. This means, that the other CPUs need to reload the content of the invalidated cache line - even if they don't really need the variable that was modified within that cache line.
This false sharing tutorial explains how false sharing can occur in Java code, as we well as what you can do to avoid false sharing in your Java apps - e.g. by using the @Contended Java annotation.
False sharing in Java - text: http://tutorials.jenkov.com/java-concurrency/false-sharing.html
Java Concurrency video playlist: https://www.youtube.com/playlist?list=PLL8woMHwr36EDxjUoCzboZjedsnhLP1j4 ... https://www.youtube.com/watch?v=tLS85IfsbYE
45963920 Bytes