summaryrefslogtreecommitdiff
path: root/jurt
diff options
context:
space:
mode:
authorNoel Grandin <noel@peralex.com>2016-06-02 15:29:00 +0200
committerNoel Grandin <noelgrandin@gmail.com>2016-06-03 09:09:23 +0000
commit0d1ce0a79e1ab1193d741df52ededf5933d93115 (patch)
treee59d3d36b7b290ac2c9d70a5d26638a1dd6bd5b7 /jurt
parentf3c1d240bd4f32d014db00a9864c56f77b7cb127 (diff)
Use AtomicLong in ThreadId instead of synchronizing
Change-Id: Ia10bab23b0cecb587cd3faa9c7e93b18384ecb88 Reviewed-on: https://gerrit.libreoffice.org/25827 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Noel Grandin <noelgrandin@gmail.com>
Diffstat (limited to 'jurt')
-rw-r--r--jurt/com/sun/star/lib/uno/environments/remote/ThreadId.java13
1 files changed, 5 insertions, 8 deletions
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 535d72782b68..f8dacc78cc48 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;