You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@kylin.apache.org by GitBox <gi...@apache.org> on 2022/10/11 11:41:36 UTC

[GitHub] [kylin] liuzhao-lz commented on a diff in pull request #1994: improve performance of getInstanceFromEnv

liuzhao-lz commented on code in PR #1994:
URL: https://github.com/apache/kylin/pull/1994#discussion_r992210473


##########
core-common/src/main/java/org/apache/kylin/common/KylinConfig.java:
##########
@@ -65,7 +65,7 @@ public class KylinConfig extends KylinConfigBase {
     public static final String KYLIN_CONF = "KYLIN_CONF";
 
     // static cached instances
-    private static KylinConfig SYS_ENV_INSTANCE = null;
+    private static volatile KylinConfig SYS_ENV_INSTANCE = null;

Review Comment:
   非 volatile 变量的读取会从主存拷到寄存器,thread1 & thread2 进入 sychronized 前SYS_ENV_INSTANCE被拷贝到各自的寄存器,假如 thread2 先执行了 sychronized 内的代码,thread2执行完后 thread1 由于SYS_ENV_INSTANCE 拷贝到寄存器,第二次判空可能结果为 true,就会再一次执行 sychronized 内的代码



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@kylin.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org