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

Thread Safety - A Theoretical Question


  • Subject: Thread Safety - A Theoretical Question
  • From: AndrĂ© Berg <email@hidden>
  • Date: Mon, 12 Oct 2009 22:47:15 +0200

Hi,

I am designing my first real class and I am wondering about thread safety. I have read the Cocoa Fundamentals and also the Threading Programming Guide but there was one question forming in my head which I couldn't quite find an answer for. I guess it is something that class designers deal differently with.

My class internally doesn't use any threads at all (well apart from an NSTask ivar and readInBackgroundAndNotify). The only scenario I can think of that would be dangerous is if in the calling code (the code from the user of my class) there are two threads which could simultaneously access the same instance of my class.

In that case is it my responsibility to guard all access to my class' thread unsafe ivars (like mutable objects for example) or is it the responsibility of the user of my class to guard all access to my class' instances in his code?

With regards to this, should I care about thread safety at all? If you are designing a class, even without any concurrency in it at all, where do you decide to worry about thread safety in code outside your reach?

I know this is a somewhat loaded question, but I do appreciate any pointers and one-liners.
Thanks a lot for reading!


Cheers,

André
_______________________________________________

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


  • Follow-Ups:
    • Re: Thread Safety - A Theoretical Question
      • From: Dave Keck <email@hidden>
    • Re: Thread Safety - A Theoretical Question
      • From: Greg Parker <email@hidden>
    • Re: Thread Safety - A Theoretical Question
      • From: Peter Duniho <email@hidden>
    • Re: Thread Safety - A Theoretical Question
      • From: Nick Zitzmann <email@hidden>
  • Prev by Date: Re: Core Data with OpenGL
  • Next by Date: Re: More Core Data Questions
  • Previous by thread: [Q] How to populate custom button of QuickTime media control?
  • Next by thread: Re: Thread Safety - A Theoretical Question
  • Index(es):
    • Date
    • Thread