• 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
Re: Synchronizing Thread Execution
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

  • Follow-Ups:
    • Re: Synchronizing Thread Execution
      • From: glenn andreas <email@hidden>
    • Re: Synchronizing Thread Execution
      • From: leenoori <email@hidden>
References: 
 >Re: Synchronizing Thread Execution (From: leenoori <email@hidden>)

  • Prev by Date: problems with modal window and menu command
  • Next by Date: Re: Creating an NSTypeSetter Subclass
  • Previous by thread: Re: Synchronizing Thread Execution
  • Next by thread: Re: Synchronizing Thread Execution
  • Index(es):
    • Date
    • Thread