File tree Expand file tree Collapse file tree 1 file changed +8
-3
lines changed
framework/ohscript/src/main/java/modelengine/fit/ohscript/util Expand file tree Collapse file tree 1 file changed +8
-3
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 ;
3839public class Tool {
3940 private static AtomicLong id = new AtomicLong (1 );
4041
42+ private static final Object lock = LockUtils .newSynchronizedLock ();
43+
4144 /**
4245 * 打印警告信息
4346 *
@@ -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
You can’t perform that action at this time.
0 commit comments