From: Hal Fulton Date: 2004-01-15T13:55:44+09:00 Subject: Re: Nested scopes and the Singleton pattern nobu.nokada@softhome.net wrote: > Hi, > > At Thu, 15 Jan 2004 13:24:19 +0900, > Hal Fulton wrote: > >>>>First question: Is this a valid way to implement Singleton, or am I >>>>overlooking something? >> >> > >> > Have you considered about race conditions? >> >>Thank you, Nobu. No, I did not consider race conditions. >> >>I suppose singleton.rb is thread safe? > > > Just using Thread.critical. And seems close to your idea > excepting for it uses "instance" method rather than "new". Actually I like "new" instead of "instance". I guess this (instance) is to emphasize that there can only be one. But I prefer simply calling new as usual, which was why I did this. Hal