Created
May 16, 2013 19:54
-
-
Save nitsanw/5594570 to your computer and use it in GitHub Desktop.
Avoiding false sharing on JDK 6/7
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// No false sharing on 6, but happens on 7 | |
public final static class VolatileLong | |
{ | |
public volatile long value = 0L; | |
public long p1, p2, p3, p4, p5, p6; | |
} | |
// No false sharing on 6 or 7 | |
public static class PaddedAtomicLong extends AtomicLong | |
{ | |
public volatile long p1, p2, p3, p4, p5, p6 = 7L; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment