• 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
Threads and synchronization (was: Re: Secondary run loops?)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Threads and synchronization (was: Re: Secondary run loops?)


  • Subject: Threads and synchronization (was: Re: Secondary run loops?)
  • From: Cem Karan <email@hidden>
  • Date: Thu, 10 Aug 2006 11:27:40 -0400

1. Start a periodic timer in your main thread and use a shared
variable to store progress information. You protect your shared
variables using @synchronized or NSLock objects if necessary (if it's
just a 32 bit integer storing progress that's not necessary).

Please use locks or @synchronized on everything that's shared, unless you are utterly certain that there is no way that corruption of the shared data can ever affect you. I've seen some very, very strange problems happen because someone decided that not locking was OK 'just this once' which can be easily avoided by locking/synchronizing.


And before you say that it's OK because it is just a 32 bit integer, yes, I HAVE seen weirdness that way too; I'll admit, it was on a misaligned data access (part of a packed struct), but still, it CAN bite you!

Thanks,
Cem Karan
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: Threads and synchronization
      • From: John Stiles <email@hidden>
  • Prev by Date: [SOLVED] Reducer / AnimatingTabView --> AnimatingScrollView
  • Next by Date: Re: Threads and synchronization
  • Previous by thread: [SOLVED] Reducer / AnimatingTabView --> AnimatingScrollView
  • Next by thread: Re: Threads and synchronization
  • Index(es):
    • Date
    • Thread