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;
}
}

+ Recent posts