应用程序 数据缓存
/// <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;
}
}
一只站在树上的鸟儿,从来不会害怕树枝会断裂,因为它相信的不是树枝,而是它自己的翅膀。与其每天担心未来,不如努力做好现在。