You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@zookeeper.apache.org by GitBox <gi...@apache.org> on 2019/03/28 18:00:08 UTC

[GitHub] [zookeeper] BELUGABEHR commented on a change in pull request #869: ZOOKEEPER-3020: Review of SyncRequestProcessor

BELUGABEHR commented on a change in pull request #869: ZOOKEEPER-3020: Review of SyncRequestProcessor
URL: https://github.com/apache/zookeeper/pull/869#discussion_r270131198
 
 

 ##########
 File path: zookeeper-server/src/main/java/org/apache/zookeeper/server/SyncRequestProcessor.java
 ##########
 @@ -102,103 +108,95 @@ public void run() {
 
             // we do this in an attempt to ensure that not all of the servers
             // in the ensemble take a snapshot at the same time
-            int randRoll = r.nextInt(snapCount/2);
+            int randRoll = ThreadLocalRandom.current().nextInt(snapCount / 2, snapCount);
 
 Review comment:
   > j.u.Random continues to be an embarrassment, and replacing uses with ThreadLocalRandom wherever we can is progress.
   
   So says the Java dev team.
   https://bugs.java.com/bugdatabase/view_bug.do?bug_id=JDK-8218282
   
   > When applicable, use of ThreadLocalRandom rather than shared Random objects in concurrent programs will typically encounter much less overhead and contention.
   
   >This class also provides additional commonly used bounded random generation methods.
   
   https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/ThreadLocalRandom.html

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services