(original) (raw)
# HG changeset patch # User shade # Date 1372150630 -14400 # Node ID d725f8f4a9db38012b6cc4b4602ccf8e65bc6c79 # Parent 8c92fa5f41cec40f6cbfa83920ef00bd54cf95d9 8014233: java.lang.Thread should have @Contended on TLR fields Summary: add the @Contended over three TLR fields. Reviewed-by: psandoz, chegar, dholmes, dl diff -r 8c92fa5f41ce -r d725f8f4a9db src/share/classes/java/lang/Thread.java --- a/src/share/classes/java/lang/Thread.java Mon Jun 17 16:28:22 2013 +0400 +++ b/src/share/classes/java/lang/Thread.java Tue Jun 25 12:57:10 2013 +0400 @@ -1993,12 +1993,21 @@ // The following three initially uninitialized fields are exclusively - // managed by class java.util.concurrent.ThreadLocalRandom. + // managed by class java.util.concurrent.ThreadLocalRandom. These + // fields are used to build the high-performance PRNGs in the + // concurrent code, and we can not risk accidental false sharing. + // Hence, the fields are isolated with @Contended. + /** The current seed for a ThreadLocalRandom */ + @sun.misc.Contended("tlr") long threadLocalRandomSeed; + /** Probe hash value; nonzero if threadLocalRandomSeed initialized */ + @sun.misc.Contended("tlr") int threadLocalRandomProbe; + /** Secondary seed isolated from public ThreadLocalRandom sequence */ + @sun.misc.Contended("tlr") int threadLocalRandomSecondarySeed; /* Some private helper methods */