Re: are the doc NSLock examples bogus?
Re: are the doc NSLock examples bogus?
- Subject: Re: are the doc NSLock examples bogus?
- From: John Stiles <email@hidden>
- Date: Sun, 12 Feb 2006 10:22:25 -0800
I guess the reader can assume that all the magic happens inside the
"..." block ;)
Seriously, the docs are definitely less than intuitive there; I'd say
file a documentation bug.
Matt Neuburg wrote:
With reference to:
<http://developer.apple.com/documentation/Cocoa/Conceptual/Multithreading/ar
ticles/CocoaLocks.html>
and this example:
BOOL moreToDo = YES;
NSLock *theLock = [[NSLock alloc] init];
...
while (moreToDo) {
/* Do another increment of calculation */
/* until thereĀ¹s no more to do. */
if ([theLock tryLock]) {
/* Update display used by all threads. */
[theLock unlock];
}
}
If this code is encountered by several different threads, then theLock is
created separately by each thread. Unless locks are magic, this would
presumably mean that locking theLock in thread A would have no effect on
theLock in thread B. So can I assume that examples of this type (which
permeate the thread docs) are just bogus?
Thx - m.
_______________________________________________
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