我正在使用带有锁对象的 SQLconnector 单例类。我现在的问题是,如果多个用户同时使用这个类,这会产生问题吗?
仅供参考...单例代码
public sealed class SqlConnector
{
private static volatile SqlConnector instance;
private static object syncRoot = new Object();
public static SqlConnector Instance
{
get
{
if (instance == null)
{
lock (syncRoot)
{
if (instance == null)
{
instance = new SqlConnector();
}
}
}
return instance;
}
}
public Execute(...)
{
//what ever
}
}