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 #904

Open
QiAnXinCodeSafe opened this issue Sep 15, 2020 · 1 comment
Open

Double-Checked Locking #904

QiAnXinCodeSafe opened this issue Sep 15, 2020 · 1 comment

Comments

@QiAnXinCodeSafe
Copy link

if (this.s3Client == null) {
synchronized (this) {
if (this.s3Client == 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.

@mattl-netflix
Copy link
Contributor

Thanks for the insights! I have a couple follow-up questions though:

Will it work as expected on an x86 architecture?
Also, would you give an example of the additional synchronization needed?

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