[Libreoffice-commits] core.git: jurt/com

Noel Grandin noel at peralex.com
Fri Jun 3 09:10:07 UTC 2016


 jurt/com/sun/star/lib/uno/environments/remote/ThreadId.java |   13 ++++--------
 1 file changed, 5 insertions(+), 8 deletions(-)

New commits:
commit 0d1ce0a79e1ab1193d741df52ededf5933d93115
Author: Noel Grandin <noel at peralex.com>
Date:   Thu Jun 2 15:29:00 2016 +0200

    Use AtomicLong in ThreadId instead of synchronizing
    
    Change-Id: Ia10bab23b0cecb587cd3faa9c7e93b18384ecb88
    Reviewed-on: https://gerrit.libreoffice.org/25827
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Noel Grandin <noelgrandin at gmail.com>

diff --git a/jurt/com/sun/star/lib/uno/environments/remote/ThreadId.java b/jurt/com/sun/star/lib/uno/environments/remote/ThreadId.java
index 535d727..f8dacc7 100644
--- a/jurt/com/sun/star/lib/uno/environments/remote/ThreadId.java
+++ b/jurt/com/sun/star/lib/uno/environments/remote/ThreadId.java
@@ -19,18 +19,15 @@
 
 package com.sun.star.lib.uno.environments.remote;
 
-import com.sun.star.uno.UnoRuntime;
 import java.io.UnsupportedEncodingException;
-import java.math.BigInteger;
 import java.util.Arrays;
+import java.util.concurrent.atomic.AtomicLong;
+
+import com.sun.star.uno.UnoRuntime;
 
 public final class ThreadId {
     public static ThreadId createFresh() {
-        BigInteger c;
-        synchronized (PREFIX) {
-            c = count;
-            count = count.add(BigInteger.ONE);
-        }
+        long c = count.getAndIncrement();
         try {
             return new ThreadId((PREFIX + c).getBytes("UTF-8"));
         } catch (UnsupportedEncodingException e) {
@@ -103,7 +100,7 @@ public final class ThreadId {
     }
 
     private static final String PREFIX = "java:" + UnoRuntime.getUniqueKey() + ":";
-    private static BigInteger count = BigInteger.ZERO;
+    private static final AtomicLong count = new AtomicLong(0);
 
     private final byte[] id;
     private int hash = 0;


More information about the Libreoffice-commits mailing list