In a Sonar report at work we have a few warnings for an Android project:
Multithreaded correctness - Incorrect lazy initialization of static field findbugs : LI_LAZY_INIT_STATIC
In order to correct these issues I was directed to the wikipedia entry on double checked locking
http://en.wikipedia.org/wiki/Double_checked_locking_pattern#Usage_in_Java
When I look through the android framework code, I do not see double checked locking employed for example, the WebViewDatabase class just makes its getInstance(Context) method synchronized:
public static synchronized WebViewDatabase getInstance(Context context) {
if (mInstance == null) {
mInstance = new WebViewDatabase(context);
}
return mInstance;
}
What is the right way in Android?
Thanks in advance