单例对象使用 volatile 关键字;

This commit is contained in:
Magese 2021-12-31 17:02:02 +08:00
parent fff131a45a
commit 7149c54de7
1 changed files with 2 additions and 2 deletions

View File

@ -44,7 +44,7 @@ public class Dictionary {
/*
* 词典单子实例
*/
private static Dictionary singleton;
private static volatile Dictionary singleton;
/*
* 主词典对象
@ -63,7 +63,7 @@ public class Dictionary {
/**
* 配置对象
*/
private Configuration cfg;
private final Configuration cfg;
/**
* 私有构造方法阻止外部直接实例化本类