Re: Thread Safety - A Theoretical Question
Re: Thread Safety - A Theoretical Question
- Subject: Re: Thread Safety - A Theoretical Question
- From: Jens Alfke <email@hidden>
- Date: Mon, 12 Oct 2009 15:43:46 -0700
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 (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