We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Dictionary类的initial方法在初始化的时候使用的双重检测方法是有问题的,不能保证在多线程环境下Dictionary单例的初始化完成。导致后续使用isStopWord方法时出现了NullPointerException,修改initial方法为在方法级别使用synchronized关键字后问题消失,修改后的代码为: public static synchronized Dictionary initial(Configuration cfg) { if (singleton == null) { singleton = new Dictionary(); singleton.configuration = cfg; singleton.loadMainDict(); singleton.loadSurnameDict(); singleton.loadQuantifierDict(); singleton.loadSuffixDict(); singleton.loadPrepDict(); singleton.loadStopWordDict(); } return singleton; }
The text was updated successfully, but these errors were encountered:
already in master
Sorry, something went wrong.
No branches or pull requests
Dictionary类的initial方法在初始化的时候使用的双重检测方法是有问题的,不能保证在多线程环境下Dictionary单例的初始化完成。导致后续使用isStopWord方法时出现了NullPointerException,修改initial方法为在方法级别使用synchronized关键字后问题消失,修改后的代码为:
public static synchronized Dictionary initial(Configuration cfg) {
if (singleton == null) {
singleton = new Dictionary();
singleton.configuration = cfg;
singleton.loadMainDict();
singleton.loadSurnameDict();
singleton.loadQuantifierDict();
singleton.loadSuffixDict();
singleton.loadPrepDict();
singleton.loadStopWordDict();
}
return singleton;
}
The text was updated successfully, but these errors were encountered: