• 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: Question about NSThread?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: Question about NSThread?


  • Subject: RE: Question about NSThread?
  • From: Stefan Sinclair <email@hidden>
  • Date: Wed, 19 Nov 2008 15:32:16 -0600
  • Importance: Normal

In a word, yes :)

If you are accessing a piece of memory across threads, you should be making sure you are synchronizing any access to that memory which could occur across threads. For simple primitives (such as possibly your work progress number) just using an atomic integer would suffice. For more complicated access, you will want better protection (such as using locks around any APIs which can access your data). You're probably getting away with it now b/c your UI thread (the main thread) is only reading data (the work progress value - I'm guessing a single integer or floating point value which can be read/written in a single instruction) while the worker thread is modifying it. But it doesn't hurt to use proper thread-safe access patterns for data shared between threads even for small things like this.

_________________________________________________________________
Proud to be a PC? Show the world. Download the “I’m a PC” Messenger themepack now.
hthttp://clk.atdmt.com/MRT/go/119642558/direct/01/_______________________________________________

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: Question about NSThread?
      • From: Jean-Nicolas Jolivet <email@hidden>
References: 
 >Question about NSThread? (From: Jean-Nicolas Jolivet <email@hidden>)

  • Prev by Date: Wrapping C functions in Objective C proxy objects: naming convention?
  • Next by Date: RE: Question about NSThread?
  • Previous by thread: Re: Question about NSThread?
  • Next by thread: Re: Question about NSThread?
  • Index(es):
    • Date
    • Thread