File tree Expand file tree Collapse file tree 1 file changed +10
-5
lines changed
framework/ohscript/src/main/java/modelengine/fit/ohscript/util Expand file tree Collapse file tree 1 file changed +10
-5
lines changed Original file line number Diff line number Diff line change 1616import modelengine .fit .ohscript .script .parser .nodes .FunctionDeclareNode ;
1717import modelengine .fit .ohscript .script .semanticanalyzer .type .expressions .TypeExprFactory ;
1818import modelengine .fitframework .beans .ObjectInstantiator ;
19+ import modelengine .fitframework .util .LockUtils ;
1920import modelengine .fitframework .util .ObjectUtils ;
2021
2122import net .bytebuddy .ByteBuddy ;
3637 * @since 1.0
3738 */
3839public class Tool {
39- private static AtomicLong id = new AtomicLong (1 ); // remove static
40+ private static final Object lock = LockUtils .newSynchronizedLock ();
41+
42+ private static AtomicLong id = new AtomicLong (1 );
4043
4144 /**
4245 * 打印警告信息
@@ -73,9 +76,11 @@ protected static void setId(long value) {
7376 /**
7477 * 初始化id,只有在id为非正数时生效
7578 */
76- private static synchronized void initId () {
77- if (id .get () <= 0 ) {
78- setId (1 );
79+ private static void initId () {
80+ synchronized (lock ) {
81+ if (id .get () <= 0 ) {
82+ setId (1 );
83+ }
7984 }
8085 }
8186
@@ -96,7 +101,7 @@ public static void grammarError(String info) {
96101 * @return 返回生成的UUID
97102 */
98103 public static String uuid () {
99- return UUIDUtil . fastUuid ( );
104+ return String . valueOf ( newId () );
100105 }
101106
102107 /**
You can’t perform that action at this time.
0 commit comments