最近写代码遇到的这样一个问题:
04-28 15:39:54.761 5589 7511 E AndroidRuntime: FATAL EXCEPTION: com.xx.xx.xx.util.xx$xx
04-28 15:39:54.761 5589 7511 E AndroidRuntime: Process: com.xx.xx.xx, PID: 5589
04-28 15:39:54.761 5589 7511 E AndroidRuntime: java.lang.NullPointerException: Null reference used for synchronization (monitor-enter)
04-28 15:39:54.761 5589 7511 E AndroidRuntime: at android.os.Parcel.readException(Parcel.java:2011)
04-28 15:39:54.761 5589 7511 E AndroidRuntime: at android.os.Parcel.readException(Parcel.java:1951)
04-28 15:39:54.761 5589 7511 E AndroidRuntime: at com.xx.xx.xx.xx$Stub$Proxy.xx(xx.java:1337)
04-28 15:39:54.761 5589 7511 E AndroidRuntime: at com.xx.xx.xx.util.xx$xx.updateStatus(xx.java:301)
04-28 15:39:54.761 5589 7511 E AndroidRuntime: at com.xx.xx.xx.util.xx$xx.xx(xx.java:243)
04-28 15:39:54.761 5589 7511 E AndroidRuntime: at com.xx.xx.xx.util.xx$xx.run(xx.java:174)
04-28 15:39:54.764 3152 6902 I am_crash: [5589,0,com.xx.xx.xx,948485709,java.lang.NullPointerException,Null reference used for synchronization (monitor-enter),Parcel.java,2011]
答案很明显,是因为我加了一个对象的同步锁,而这个对象被我初始化为null,所以导致该NullPointerException,切记同步锁的对象不能为null。