Singleton模式是一個較為簡單的模式
{
//申明一個靜態的變量
private static LogWriter _instance = null;
//將類的構造函數私有化
private LogWriter()
{
}
//提供靜態的方法
public static LogWriter GetInstance()
{
if (_instance == null)
{
_instance = new LogWriter();
}
return _instance;
}
}
From:http://tw.wingwit.com/Article/program/Java/gj/201311/27605.html