Re: Accessing array in thread safe way
Re: Accessing array in thread safe way
- Subject: Re: Accessing array in thread safe way
- From: "Stephen J. Butler" <email@hidden>
- Date: Tue, 06 Mar 2012 16:24:54 -0600
On Tue, Mar 6, 2012 at 1:51 PM, Jan E. Schotsman <email@hidden> wrote:
> I have an array of progress values (number objects) for subprojects, from
> which I calculate the overall progress .
> The array is an atomic property of the project class.
>
> Is it safe to access this array from multiple threads, using methods like
> objectAtIndex and replaceObjectAtIndex?
This is an NSMutableArray? No.
The atomic only means it's safe to access the *property* from multiple
threads. But it doesn't say anything about the thread safety of what
you do with the object stored in the property.
If you limit your array accesses to only the methods contained in
NSArray then things are okay. But as soon as you start mixing any
NSMutableArray methods the whole thing becomes unsafe (including those
previously safe NSArray methods).
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden