getInstance時空指針
if (mImageLoader == null) {
? ?synchronized (mImageLoader) {
? ? ? ?if (mImageLoader == null) {
? ? ? ? ? ?mImageLoader = new ImageLoader(threadCount, type);
? ? ? ?}
? ?}
}使用同步時,報NPE,老師怎么解決?貌似,當對象為空時,不能用synchronized
if (mImageLoader == null) {
? ?synchronized (mImageLoader) {
? ? ? ?if (mImageLoader == null) {
? ? ? ? ? ?mImageLoader = new ImageLoader(threadCount, type);
? ? ? ?}
? ?}
}使用同步時,報NPE,老師怎么解決?貌似,當對象為空時,不能用synchronized
2016-12-08
舉報
2016-12-12
加鎖的時候 你加錯了 用.類的class加鎖