• 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: Thread Safety - A Theoretical Question
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


References: 
 >Thread Safety - A Theoretical Question (From: André Berg <email@hidden>)
 >Re: Thread Safety - A Theoretical Question (From: Dave Keck <email@hidden>)

  • Prev by Date: Re: [UTI] Anyway to retrieve the UTI of a file without having to use a FSRef?
  • Next by Date: Re: [UTI] Anyway to retrieve the UTI of a file without having to use a FSRef?
  • Previous by thread: Re: Thread Safety - A Theoretical Question
  • Next by thread: Re: Thread Safety - A Theoretical Question
  • Index(es):
    • Date
    • Thread