• 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: Dave MacLachlan <email@hidden>
  • Date: Wed, 6 Dec 2006 09:10:32 -0800


On Dec 05, 2006, at 08:43 , Clark Cox wrote:

On 12/5/06, Buddy Kurz <email@hidden> wrote:
FYI: The Darwin source contains a comment that specifically says
@synchronized(nil) does nothing.

I'm wondering what the difference is between
@synchronized(myObject) {
//do stuff
}
and
{
[myLock lock];
//do stuff
[myLock unlock];
}

@synchronized(myObject) { foo; }

is more like:

@try
{
 [myLock lock];
 foo;
}
@finally
{
 [myLock unlock];
}

That is, it will be unlocked when an exception is thrown, or you
return from the current function, etc.

Probably should also be noted that the lock here under discussion that the lock is a recursive lock. So for these to be equivalent, myLock must be an NSRecursiveLock, not just a plain NSLock.


Cheers,
Dave
_______________________________________________

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


References: 
 >Re: Synchronizing Thread Execution (From: Scott Ribe <email@hidden>)
 >Re: Synchronizing Thread Execution (From: Buddy Kurz <email@hidden>)
 >Re: Re: Synchronizing Thread Execution (From: "Clark Cox" <email@hidden>)

  • Prev by Date: Re: Deciding whether text should be black or white for a given background color
  • Next by Date: Re: thread spinning ...
  • Previous by thread: Re: Re: Synchronizing Thread Execution
  • Next by thread: Re: Synchronizing Thread Execution
  • Index(es):
    • Date
    • Thread