Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import modelengine.fit.ohscript.script.parser.nodes.FunctionDeclareNode;
import modelengine.fit.ohscript.script.semanticanalyzer.type.expressions.TypeExprFactory;
import modelengine.fitframework.beans.ObjectInstantiator;
import modelengine.fitframework.util.LockUtils;
import modelengine.fitframework.util.ObjectUtils;

import net.bytebuddy.ByteBuddy;
Expand All @@ -36,7 +37,9 @@
* @since 1.0
*/
public class Tool {
private static AtomicLong id = new AtomicLong(1); // remove static
private static final Object lock = LockUtils.newSynchronizedLock();

private static AtomicLong id = new AtomicLong(1);

/**
* 打印警告信息
Expand Down Expand Up @@ -73,9 +76,11 @@ protected static void setId(long value) {
/**
* 初始化id,只有在id为非正数时生效
*/
private static synchronized void initId() {
if (id.get() <= 0) {
setId(1);
private static void initId() {
synchronized (lock) {
if (id.get() <= 0) {
setId(1);
}
}
}

Expand All @@ -96,7 +101,7 @@ public static void grammarError(String info) {
* @return 返回生成的UUID
*/
public static String uuid() {
return UUIDUtil.fastUuid();
return String.valueOf(newId());
}

/**
Expand Down