using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace VisimBox
{
    /// <summary>
    /// Class for implementing singleton approach
    /// Multithreaded safe version with locking
    /// </summary>
    public class Singleton<T> where T : class, new()
    {
        static T instance = null;
        static readonly object padlock = new object();

        public Singleton() { }

        public static T Instance
        {
            get
            {
                lock (padlock)
                {
                    if (instance == null)
                        instance = new T();
                }

                return instance;
            }
        }
    }
}
