开发者

NSMutableArray is thread safe?

开发者 https://www.devze.com 2023-02-11 23:42 出处:网络
Can anybody give me example that NSM开发者_JAVA技巧utableArray is thread safe or not?It is not thread safe. See the list of thread safe/unsafe classes hereAccording to the Apple docs NSMutableArray is

Can anybody give me example that NSM开发者_JAVA技巧utableArray is thread safe or not?


It is not thread safe. See the list of thread safe/unsafe classes here


According to the Apple docs NSMutableArray is not thread safe.

Mutable objects are generally not thread-safe. To use mutable objects in a threaded application, the application must synchronize access to them using locks. (For more information, see “Atomic Operations”). In general, the collection classes (for example, NSMutableArray, NSMutableDictionary) are not thread-safe when mutations are concerned. That is, if one or more threads are changing the same array, problems can occur. You must lock around spots where reads and writes occur to assure thread safety.

http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/Multithreading/ThreadSafetySummary/ThreadSafetySummary.html

0

精彩评论

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

关注公众号