• 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: @synchronized question
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: @synchronized question


  • Subject: Re: @synchronized question
  • From: Mel Walker <email@hidden>
  • Date: Mon, 24 May 2004 13:06:20 -0600

On May 24, 2004, at 12:11 PM, Clark Cox wrote:
On May 24, 2004, at 12:15, Mel Walker wrote:
-(void)doSomething {
@synchronized(myTextView) {
...
}
}

or should I do something like this:

-(void)doSomething {
@synchronized(self) {
...
}
}

Which one you use depends on which object you're trying to protect access to. So, for instance, if you have another method:

-(void)doSomethingElse
{
@synchronized(self)
{
//Something that may have nothing to do with myTextView
}
}

This could be blocked if the (self) version of doSomething is currently running, but won't be blocked if the (myTextView) version is running. Either way, you should try to be consistent.

Thanks for that explanation. Let's see if I've got it --

@synchronized(someObject) {}

is the equivalent of:

{
[someObjectsLock lock];
// use someObject here
[someObjectsLock unlock];
}

correct? Which is better to use?

--
Mel Walker <email@hidden>
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.


References: 
 >@synchronized question (From: Mel Walker <email@hidden>)
 >Re: @synchronized question (From: Clark Cox <email@hidden>)

  • Prev by Date: Re: Calling an Action from a function
  • Next by Date: Re: @synchronized question
  • Previous by thread: Re: @synchronized question
  • Next by thread: Re: @synchronized question
  • Index(es):
    • Date
    • Thread