I think there's actually a typo in the second sentence. If you look in the 
Thread-Safe section above that, it refers to instances: "The following classes 
and functions are generally considered to be thread-safe. You can use the same 
instance from multiple threads without first acquiring a lock."

For the documentation to contrast classes with thread-safe instances against 
classes which are entirely thread-unsafe would not make sense. I think it's 
supposed to be: "In most cases, you can use **instances of **these classes from 
any thread as long as you use them from only one thread at a time."

And I don't believe Jerry's rewording is correct. It looks like everything in 
the unsafe list is either mutable or maintains some internal state which would 
get trampled by concurrent calls. You should be able to share thread-unsafe 
instances with other threads, just as long as only one thread is using them at 
a time.

Justin

On May 19, 2011, at 6:06 PM, Sean McBride wrote:

> On Thu, 19 May 2011 14:31:23 -0700, Quincey Morris said:
> 
>> On May 19, 2011, at 13:56, Sean McBride wrote:
>> 
>>>> Would it be correct to restate it
>>>> like this…
>>>> 
>>>> "In most cases, although you can allocate instances of these classes on
>>>> any thread, each instance must receive messages only from the thread
>>>> which allocated it."
>>> 
>>> I believe so.  
>> 
>> I don't believe so.
> 
> Did you look at the classes listed under that section?
> 
> <http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/
> Multithreading/ThreadSafetySummary/ThreadSafetySummary.html>
> 
> NSMutableData is one.  If Apple's wording is correct, that means I can't
> create two threads, each of which creates and manipulates its *own*
> NSMutableData instances (but doesn't share these objects with other
> threads!).  That just seems unlikely to me.  How could you ever use
> NSMutableData on a non-main thread if so?  Who's to say some OS-created
> thread is not also using NSMutableData?
> 
> I do think Jerry is right; they mean you can create NSMutableDatas on
> any thread, as long as you don't share the instances with other threads.

_______________________________________________

Cocoa-dev mailing list ([email protected])

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to