8014233: java.lang.Thread should have @Contended on TLR fields
authorshade
Tue, 25 Jun 2013 20:06:09 +0100
changeset 18550 6d0f51c99930
parent 18549 66e6e111be22
child 18551 882a3948c6e6
8014233: java.lang.Thread should have @Contended on TLR fields Summary: add the @Contended over three TLR fields. Reviewed-by: psandoz, chegar, dholmes, dl
jdk/src/share/classes/java/lang/Thread.java
--- a/jdk/src/share/classes/java/lang/Thread.java	Tue Jun 25 21:51:11 2013 +0800
+++ b/jdk/src/share/classes/java/lang/Thread.java	Tue Jun 25 20:06:09 2013 +0100
@@ -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 */