G
Guest
Hello All,
I am trying to implement a singleton pattern as follows:
public sealed class Singleton
{
private static readonly Singleton only = new Singleton() ;
public static Singleton Instance
{
get
{
return only ;
}
}
..... rest of implementation.....
}
Now my question is if two threads access Singleton.Instance method
simultaneously is there a possibility of creating 2 instances of Singleton
class?
Why or why not?
Thanks!!
I am trying to implement a singleton pattern as follows:
public sealed class Singleton
{
private static readonly Singleton only = new Singleton() ;
public static Singleton Instance
{
get
{
return only ;
}
}
..... rest of implementation.....
}
Now my question is if two threads access Singleton.Instance method
simultaneously is there a possibility of creating 2 instances of Singleton
class?
Why or why not?
Thanks!!