• 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: NSMutableData and thread safety
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSMutableData and thread safety


  • Subject: Re: NSMutableData and thread safety
  • From: Ken Thomases <email@hidden>
  • Date: Thu, 25 Sep 2008 10:17:21 -0500

On Sep 25, 2008, at 8:50 AM, Roman Kishchenko wrote:

It is said in the documentation that NSMutableData is not thread- safe. So,
its access needs to be synchronized, at least, when multiple contending
threads are using the object of this class. However, is synchronization
necessary when NSMutableData is used by multiple threads NOT concurrently,
i.e. first one thread adds some data to it, the the other, etc?

If you can guarantee that only one thread is accessing the object at a time, then that _is_ synchronization.



Also, is it ok to pass the object of this class as an argument to
performSelector:onThread:...?

Yes, that's safe so long as the calling thread doesn't access the object after it has been passed as an argument (unless such access is synchronized with the receiving thread).


Cheers,
Ken

_______________________________________________

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


References: 
 >NSMutableData and thread safety (From: "Roman Kishchenko" <email@hidden>)

  • Prev by Date: NSMutableData and thread safety
  • Next by Date: Re: What does @loader_path refer to when loading ibplugins from a linked-in framework?
  • Previous by thread: NSMutableData and thread safety
  • Next by thread: How to set up a thread listening to performSelector: messages?
  • Index(es):
    • Date
    • Thread