static void Main(string[] args) { var thread1 = new Thread(() => OngdevSingleton.GetInstance().SaysHi()); var thread2 = new Thread(() => OngdevSingleton.GetInstance().SaysHi()); thread1.Start(); thread2.Start(); }
public static OngdevSingleton GetInstance() { if (uniqueInstance == null) { lock (lockObject) { if (uniqueInstance == null) { var random = new Random(); uniqueInstance = new OngdevSingleton(random.Next(1, 4)); } } } return(uniqueInstance); }