On Oct 12, 2009, at 2:47 PM, Dave Keck wrote:

I recommend adopting this rule too, and only making classes thread
safe if it makes sense.

+1

While making every class you ever write
thread-safe might be a good intellectual exercise, it's hard and time
consuming, and I doubt there's many of us who do it.

I'll go farther: thread-safety is nearly impossible, largely because it can't be modularized. Most classes can't be made thread-safe on their own, because behaviors can arise from interactions between classes. The situations get pretty pathological.

I almost never code for thread-safety. In the few situations where I have code running on background threads (like using NSOperations) I make sure that the background thread doesn't use any of the same objects as the main thread, except for a few immutable ones like NSString. This kind of message-passing model is gaining a lot of traction lately.

—Jens_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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 arch...@mail-archive.com

Reply via email to