Re: Synchronizing Thread Execution
Re: Synchronizing Thread Execution
- Subject: Re: Synchronizing Thread Execution
- From: Antonio Nunes <email@hidden>
- Date: Tue, 5 Dec 2006 03:15:17 +0000
On 4 Dec 2006, at 18:54, leenoori wrote:
That's what I thought too, but after some experimentation it
doesn't seem to work, or I am misunderstanding what it means.
Using the above expression it seems the objects are being modified
from somewhere else while we are in the critical region. Using
@synchronized(self) this doesn't happen. But this last expression
still doesn't provide enough protection:
Can't you just stick a file-scoped static variable somewhere and
@synchronize on that?
eg.
// single static variable shared by all instances:
static id foo = nil;
@implementation Thing
- (void)method
{
@synchronized(foo)
{
// do something
}
}
@end
Thanks for the suggestion, but it it didn't work. It gave more
problems than using @synchronized(self) in that the results were
similar to those using @synchronized(NSStringFromSelector(_cmd)),
namely re-entry within the same object.
-António
-----------------------------------------------------------
And could you keep your heart in wonder
at the daily miracles of your life,
your pain would not seem less wondrous
than your joy.
--Kahlil Gibran
-----------------------------------------------------------
_______________________________________________
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