Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Threading;
- using System.Linq;
- class Program
- {
- static void Main(string[] args)
- {
- (new Thread(()=>
- {
- var sing = Singleton.GetInstance();
- Console.WriteLine(sing.Date);
- })).Start();
- var sing2 = Singleton.GetInstance();
- Console.WriteLine(sing2.Date);
- Console.ReadLine();
- }
- }
- class Singleton
- {
- private static readonly Singleton instance = new Singleton();
- public string Date{get; private set;}
- private Singleton()
- {
- this.Date = DateTime.Now.TimeOfDay.ToString();
- }
- public static Singleton GetInstance()
- {
- return instance;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement