• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Accessing array in thread safe way
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Accessing array in thread safe way


  • Subject: Re: Accessing array in thread safe way
  • From: Marco Tabini <email@hidden>
  • Date: Tue, 06 Mar 2012 17:10:01 -0500

On 2012-03-06, at 2:51 PM, Jan E. Schotsman wrote:

> Hello,
>
> 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?
>

NSMutableArray is not (as far as I know) thread-safe while being mutated[1]. That said, it doesn't mean that you can't use the array in a multi-threaded environment: Just make sure that writes are all synchronized, and that enumerations only happen on immutable copies.

HTH,


—Mt.



[1]: https://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/Multithreading/ThreadSafetySummary/ThreadSafetySummary.html


_______________________________________________

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


  • Follow-Ups:
    • Re: Accessing array in thread safe way
      • From: Per Bull Holmen <email@hidden>
References: 
 >Accessing array in thread safe way (From: "Jan E. Schotsman" <email@hidden>)

  • Prev by Date: Re: JSON validator for Xcode
  • Next by Date: Re: JSON validator for Xcode
  • Previous by thread: Accessing array in thread safe way
  • Next by thread: Re: Accessing array in thread safe way
  • Index(es):
    • Date
    • Thread