• 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: Singleton instances and multithreading
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Follow-Ups:
    • Re: Singleton instances and multithreading
      • From: Gareth White <email@hidden>
    • Re: Singleton instances and multithreading
      • From: "Axel 'Mikesch' Katerbau" <email@hidden>
References: 
 >Re: Singleton instances and multithreading (From: Mike Shields <email@hidden>)

  • Prev by Date: Re: Singleton instances and multithreading
  • Next by Date: Re: Cocoa undo considerations
  • Previous by thread: Re: Singleton instances and multithreading
  • Next by thread: Re: Singleton instances and multithreading
  • Index(es):
    • Date
    • Thread