I have a property (atomic, retain) NSString *identifier which may be read from multiple thread. So which is the correct way to make it thread safe-
- (NSString *)identifier
{ @synchronized(self)
{
return [_identifier retain] autorelease];
}
}
or
- (NSString *)identifier
{ @synchronized(identifier)
{
return [_identifier retain] autorelease];
}
}
Infact, i want to know the purpose of key parameter is @synchronize(key). Thanks for you help.
atomicattribute will do the right thing; why are you generating the getter yourself? - Droppy