Re: Singleton instances and multithreading
Re: Singleton instances and multithreading
- Subject: Re: Singleton instances and multithreading
- From: Rob Rix <email@hidden>
- Date: Thu, 12 Jul 2001 01:38:16 -0400
So, just to be sure that I'm doing the correct thing, here's my singleton
method:
+ sharedScanner
{
static CBGFileSystemScanner *sharedScanner = nil;
NSRecursiveLock *theLock = [[NSRecursiveLock alloc] init];
[theLock lock];
if (!sharedScanner)
sharedScanner = [[self alloc] init];
[theLock unlock];
[theLock release];
return [sharedScanner autorelease];
}
Is that the right thing to do?
Thanks again,
-- Rob
If there's anything more important than my ego around, I want it caught
and shot now. - Zaphod