Skip to content
New issue

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

Double-Checked Locking #160

Open
QiAnXinCodeSafe opened this issue Oct 12, 2020 · 3 comments
Open

Double-Checked Locking #160

QiAnXinCodeSafe opened this issue Oct 12, 2020 · 3 comments

Comments

@QiAnXinCodeSafe
Copy link

if (map == null)
{
if ((CompilerDiagnosticsConstants.diagnostics & CompilerDiagnosticsConstants.ASSCOPECACHE) == CompilerDiagnosticsConstants.ASSCOPECACHE)
System.out.println("ASScopeCache waiting for lock in getScopeChainMap");
synchronized (this)
{
// Check again, in case another thread updated the map first
map = findPropCache != null ? findPropCache.get() : null;
if (map == null)

Double-Checked Locking is widely cited and used as an efficient method for implementing lazy initialization in a multithreaded environment.
Unfortunately, it will not work reliably in a platform independent way when implemented in Java, without additional synchronization.

@carlosrovira
Copy link
Contributor

Hi, thanks for the information. Could you please let us know as a better way of doing it submitting a patch. We'll be glad to integrate any improvement.
thanks

@QiAnXinCodeSafe
Copy link
Author

Hi, thanks for the information. Could you please let us know as a better way of doing it submitting a patch. We'll be glad to integrate any improvement.
thanks
Modify the variable map with volatile.

@carlosrovira
Copy link
Contributor

Hi @QiAnXinCodeSafe, if you can submit a Pull Request it would be better and would make your collaborations and out testing more productive. Could you send as a PR for this issue?
thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants