|
|
|
blahetal
Community Member
|
|
|
Hi, is your implementation of Singleton thread-safe?
|
|
|
|
|
Ignacio Vivona
Community Member
|
|
The current implementation use the static constructor to initialize the static variable that holds the singleton. Static constructors are called by the run-time at most once. So i believe they are thread-safe, but there is a lot to read with a simple google search about the issue. If someone can say a word about this is welcome to do so.
Cheers. Ignacio
|
|
|
|
|
blahetal
Community Member
|
|
Ok, I found this article http://www.yoda.arachsys.com/csharp/singleton.html
and from your post I understand that you use the first method (to create a Singleton) that is described in the article above. Well, and there is written that using pure static constructors (without any synchronization mechanism) is not thread safe. Could you check it.
|
|
|
|
|
Ignacio Vivona
Community Member
|
|
I have read that, but what i do is close to the fourth form. I do the initialization in the static constructor, the accessor only retrieves the instance.
Ignacio.
|
|
|
|