> From: "Felipe Schnack" <[EMAIL PROTECTED]> > Sent: Wednesday, February 05, 2003 4:05 AM > Subject: RE: singleton creation (ot)
> I'm not sure yet of how I will do it... I would not like to > synchronize the entire method because it'll probably be called million > of times in my app Then don't call it a million times in your app. Call it once at startup and stick it in a property in the Context. (Of course, calls to get properties out of the context may be synchronized, I haven't looked.) Or simply don't synchronize it and load the singleton at startup, when you are in more control of the environment and have confidence that a race condition isn't happening, or at least is not important. The whole point of the synchronize is to serialize requests during race conditions. Make the requests when this isn't happening and be done with it. The generic Singleton pattern works fine when applied genericly to generic code. In this case you have a higher knowledge of how its being used and can make decisions based upon that knowledge. Finally, as a self-rebuttal, "Don't worry about it at all unless it becomes a problem. Early optimization is the source of many evils". Regards, Will Hartung ([EMAIL PROTECTED]) --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
