Yes you are right -- I did all the locking code because I wanted to
match exactly the singleton pattern describe in the GoF book... The key
point being that the resources is not allocated until it is really
needed -- as a said I think this is rarely needed.

..brad

-----Original Message-----
From: Frank Hileman [mailto:[EMAIL PROTECTED]] 
Sent: Thursday, June 06, 2002 8:20 AM
To: [EMAIL PROTECTED]
Subject: Re: [ADVANCED-DOTNET] Singleton pattern


Hello Brad Adams,

Why do you have all this locking code? A static constructor is already
thread-safe. From C# spec:

"The static constructor for a class executes at most one time during a
single program instantiation"

You can read messages from the Advanced DOTNET archive, unsubscribe from
Advanced DOTNET, or subscribe to other DevelopMentor lists at
http://discuss.develop.com.

You can read messages from the Advanced DOTNET archive, unsubscribe from Advanced 
DOTNET, or
subscribe to other DevelopMentor lists at http://discuss.develop.com.

Reply via email to