Re: NSMutableData and thread safety
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