Advertisements

Thursday, April 4, 2013

Java singleton sample

Ejemplo de como implementar el patron de diseño "Singleton".
01private synchronized static void createInstance(){
02    if(INSTANCE == null){
03      INSTANCE = new StockCountMRG();
04    }
05}
06 
07public static StockCountMRG getInstance(){
08  createInstance();
09  return INSTANCE;
10}

No comments:

Post a Comment