You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@accumulo.apache.org by GitBox <gi...@apache.org> on 2020/03/31 18:14:11 UTC

[GitHub] [accumulo] ivakegg commented on a change in pull request #1487: Fixes: #1323 Implement a write thread limit

ivakegg commented on a change in pull request #1487: Fixes: #1323 Implement a write thread limit
URL: https://github.com/apache/accumulo/pull/1487#discussion_r401110573
 
 

 ##########
 File path: server/tserver/src/main/java/org/apache/accumulo/tserver/TabletServer.java
 ##########
 @@ -495,6 +501,14 @@ private static long jitter() {
     // add a random 10% wait
     return (long) ((1. + (r.nextDouble() / 10)) * TabletServer.TIME_BETWEEN_LOCATOR_CACHE_CLEARS);
   }
+  
+    //synchronized method to control simultaneous access
+  synchronized private Semaphore getSemaphore() {
+    if (sem == null) {
 
 Review comment:
   to avoid some synchronization here, try something like this:
   ```
    private Semaphore getSemaphore() {
     if (sem == null) {
       synchronized(this) {
         if (sem == null) {
           sem = new Semaphore(maxThreadPermits);
         }
       }
       return sem;
     }
   ```

----------------------------------------------------------------
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