Re: are the doc NSLock examples bogus?
Re: are the doc NSLock examples bogus?
- Subject: Re: are the doc NSLock examples bogus?
- From: Keith Ray <email@hidden>
- Date: Sun, 12 Feb 2006 10:27:18 -0800
It could be more explicit, but the "..." (line 3 of this code example)
apparently means to imply that these are two separate pieces of code:
a piece that contains the initialization of the lock and is only
executed once, and another piece of code (in another method) that
could be run by multiple threads.
On 2/12/06, Matt Neuburg <email@hidden> 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.
>
> --
> 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
>
--
C. Keith Ray
<http://homepage.mac.com/keithray/blog/index.html>
<http://homepage.mac.com/keithray/xpminifaq.html>
<http://homepage.mac.com/keithray/resume2.html>
_______________________________________________
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