• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
are the doc NSLock examples bogus?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

  • Follow-Ups:
    • Re: are the doc NSLock examples bogus?
      • From: Uli Kusterer <email@hidden>
    • Re: are the doc NSLock examples bogus?
      • From: Keith Ray <email@hidden>
    • Re: are the doc NSLock examples bogus?
      • From: John Stiles <email@hidden>
  • Prev by Date: Re: Affine Transform
  • Next by Date: Re: are the doc NSLock examples bogus?
  • Previous by thread: Custom NSMenu on NSSearchField question
  • Next by thread: Re: are the doc NSLock examples bogus?
  • Index(es):
    • Date
    • Thread