facebookarchive / stetho

Stetho is a debug bridge for Android applications, enabling the powerful Chrome Developer Tools and much more.
http://facebook.github.io/stetho/
MIT License
12.66k stars 1.13k forks source link

Double-Checked Locking #688

Open QiAnXinCodeSafe opened 3 years ago

QiAnXinCodeSafe commented 3 years ago

https://github.com/facebook/stetho/blob/5cc93ec78908cdded19c5352a90635a33cf2fa7f/stetho/src/main/java/com/facebook/stetho/inspector/helper/IntegerFormatter.java#L19-L21

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.