Re: Synchronizing Thread Execution
Re: Synchronizing Thread Execution
- Subject: Re: Synchronizing Thread Execution
- From: Scott Ribe <email@hidden>
- Date: Mon, 04 Dec 2006 18:04:48 -0700
- Thread-topic: Synchronizing Thread Execution
> // single static variable shared by all instances:
> static id foo = nil;
Not good. Whether it uses some methods of NSObject and fails right away, or
whether it just uses the pointer to access a lock via hash and fails after
you try this with a second variable in some other class. But this should be
fine:
static id foo = [[NSObject alloc] init];
Or, if this is really global and integral to the app, you could lock on a
singleton, NSApp for instance. I wouldn't do that, because it could
unnecessarily serialize things if you or someone else later adds another
class with this kind of locking need and does the same thing. Maybe not
likely in this program, but cleaner to lock on an object that is intended to
have the exact locking "scope" needed...
--
Scott Ribe
email@hidden
http://www.killerbytes.com/
(303) 722-0567 voice
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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