I am using below code for Implementing singleton instance and store some data in it as a list and access across class files in project. My question is what will happen if this project is hosted in two servers whether two instance will be created. Because i think it will create two instance if it is from two servers,That is what i need even. Code below Two questions: 1.How many instance if same server and multiple web site? 2.How many instance if two different server?
public class XXX {
private static XXX _instance;
// Lock synchronization object
private static readonly object SyncLock = new object();
private XXX()
{
}
public static XXX Instance
{
get
{
if (_instance == null)
{
lock (SyncLock)
{
if (_instance == null)
{
_instance = new XXX();
}
}
}
return _instance;
}
}
public List<XXX> XXXDetails { get { return _XXX ; } set { _XXX = value; } }
private List<XXX> _XXX = new List<XXX>();
}