我在Google sample project中找到了以下代码,这是一个单例的简单The method scheduleToPrint(List<NumberWrapper<?,?>>) in the type
Scheduler<NumberWrapper<?,?>> is not applicable for the arguments
(List<DoubleWrapper>)
方法实现:
getInstance()
我们非常清楚为什么我们第一次检查public static AppDatabase getInstance(final Context context, final AppExecutors executors) {
if (sInstance == null) {
synchronized (AppDatabase.class) {
if (sInstance == null) { // why do we check this?
sInstance = buildDatabase(context.getApplicationContext(), executors);
sInstance.updateDatabaseCreated(context.getApplicationContext());
}
}
}
return sInstance;
}
sInstance
,但为什么我们也会在null
块中检查它?< / p>
如果有人能解释一下,我真的很感激。