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
原文:如果2和3进行了重排序的话,线程B进行判断if(instance==null)时就会为true,而实际上这个instance并没有初始化成功,显而易见对线程B来说之后的操作就会是错得。
在解释双重加锁的时候提到指令重排序后,如果先分配内存地址而不是先初始化,内存地址现在已经有值,那么if(instance==null)是不是应该返回为false
if(instance==null)
The text was updated successfully, but these errors were encountered:
是的,我也觉得这里写错了。 参考https://blog.csdn.net/glory1234work2115/article/details/50814419
Sorry, something went wrong.
No branches or pull requests
在解释双重加锁的时候提到指令重排序后,如果先分配内存地址而不是先初始化,内存地址现在已经有值,那么
if(instance==null)
是不是应该返回为falseThe text was updated successfully, but these errors were encountered: