summaryrefslogtreecommitdiff
path: root/SurvivalTest/Assets/Scripts/Test/TestSingleton.cs
blob: d52265301a4fb5b4b3a2f7bac5f39e5bcb0dc43a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
public class TestSingleton<T> where T : class, new()
{
	private static T _instance;
	private static readonly object syslock = new object();

	public static T getInstance()
	{
		if (_instance == null)
		{
			lock (syslock)
			{
				if (_instance == null)
				{
					_instance = new T();
				}
			}
		}
		return _instance;
	}
}