public sealed class singltone
{
static volatile singltone instance = null;
static readonly object obj = new object();
singltone()
{ }
public static singltone Instance
{
get
{
lock (obj)
{
if (instance == null)
{
instance = new singltone();
}
return instance;
}
}
}
public void write()
{
Console.WriteLine("HI THERE");
}
}
class Program
{
static void Main(string[] args)
{
singltone.Instance.write();
}
}
No comments:
Post a Comment