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>
This commit is contained in:
parent
f3c1d240bd
commit
0d1ce0a79e
1 changed files with 5 additions and 8 deletions
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue