Threads and synchronization (was: Re: Secondary run loops?)
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