Singleton
public class Singleton{ //static field private static Singleton instance; //private(protected) constructor: class ๋ฐ์์๋ object ์์ฑ X. private Singleton(){...} //static member function (static factory method) //synchronized: thread์์ ๋์์ ๊ทผ์ ๋ํ ๋ฌธ์ ํด๊ฒฐ (์ฑ๋ฅ ์ ํ ์์ธ) public static synchronized Singleton getInstance(){ //lazy init if(instance == null) instance = new SingleTon(?); return instance; } }
Last updated