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
http://luokangyuan.com/si-ke-she-ji-mo-shi-dan-li-mo-shi/
The text was updated successfully, but these errors were encountered:
所有懒加载里面,在初始化完成,需要将new的对象复制,最后返回这个变量,而不是直接返回。
public static Singleton getInstance() { if (singleton == null) { synchronized (Singleton.class) { if (singleton == null) { return new Singleton(); } } } return singleton; }
建议修改成这样
public static Singleton getInstance() { if (singleton == null) { synchronized (Singleton.class) { if (singleton == null) { singleton = new Singleton(); } } } return singleton; }
Sorry, something went wrong.
感谢指出,已修改
No branches or pull requests
http://luokangyuan.com/si-ke-she-ji-mo-shi-dan-li-mo-shi/
The text was updated successfully, but these errors were encountered: