You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

29 lines
648 B
C#

using System;
namespace ZJ_BYD.Untils
{
public class Singleton<T> where T : class, new()
{
private static T _instance;
protected static readonly object SyncLock = new object();
public static T Instance
{
get
{
if (_instance == null)
{
lock (SyncLock)
{
if (_instance == null)
{
_instance = new T();
}
}
}
return _instance;
}
}
}
}