Java
[Java] Singleton 패턴...
빤따스뤽
2007. 1. 9. 21:59
public static class Singleton1
{
pirvate static final Singleton1 theInstance = new Singleton1();
public static Singleton1 getInstance()
{
return theInstance;
}
}
혹은...
public static class Singleton2
{
private static Singleton2 theInstance;
public static synchronized Singleton2 getInstance()
{
if (theInstance == null)
theInstance = new Singleton2();
return theInstance;
}
}