开发者

Is java.util.Observable in Android thread-safe?

Is java.util.Observable in Android thread-safe? The documentation says that only deleteObserver() and deleteObservers() are synchronized methods. What about addObserver(), set/clear/hasChanged()? Can I safely call 开发者_StackOverflow中文版addObserver() from different threads without locking around the Observable object?


AFAIK, Android is based on Apache Harmony. I found the source code of the the Observable implementation of Harmony here : http://www.java2s.com/Open-Source/Java-Document/Apache-Harmony-Java-SE/java-package/java/util/Observable.java.htm.

It seems to me that the tried to make it thread-safe, but failed : they forgot to synchronize the countObservers method, as well as the set/has/clearChanged methods.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜