/// <summary>
/// 通过单利模式 实现数据程序缓存
/// DataInstanct.GetInstan().Add(0)[写入数据]
/// DataInstanct.GetInstan().Clear()[清空数据存储]
/// </summary>
public class DataInstance
{
/// <summary>
/// 数据仓库
/// </summary>
public static List<int> dataWarehouse = new List<int>();
private readonly static DataInstanct instan = new DataInstanct();
private static object obj=new object ();
public static DataInstanct GetInstan()
{
return instan;
}
public DataInstanct()
{
}
public void Clear()
{
dataWarehouse = new List<int>();
}
public int Add(int i)
{
lock (obj)
{
list.Add(i);
}
return list.Count;
}
}
/// 通过单利模式 实现数据程序缓存
/// DataInstanct.GetInstan().Add(0)[写入数据]
/// DataInstanct.GetInstan().Clear()[清空数据存储]
/// </summary>
public class DataInstance
{
/// <summary>
/// 数据仓库
/// </summary>
public static List<int> dataWarehouse = new List<int>();
private readonly static DataInstanct instan = new DataInstanct();
private static object obj=new object ();
public static DataInstanct GetInstan()
{
return instan;
}
public DataInstanct()
{
}
public void Clear()
{
dataWarehouse = new List<int>();
}
public int Add(int i)
{
lock (obj)
{
list.Add(i);
}
return list.Count;
}
}