are the doc NSLock examples bogus?
are the doc NSLock examples bogus?
- Subject: are the doc NSLock examples bogus?
- From: Matt Neuburg <email@hidden>
- Date: Sun, 12 Feb 2006 09:50:15 -0800
- Thread-topic: are the doc NSLock examples bogus?
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.
--
matt neuburg, phd = email@hidden, <http://www.tidbits.com/matt/>
A fool + a tool + an autorelease pool = cool!
AppleScript: the Definitive Guide
<http://www.amazon.com/exec/obidos/ASIN/0596005571/somethingsbymatt>
_______________________________________________
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