Advertisements

Thursday, April 4, 2013

Java singleton sample

Ejemplo de como implementar el patron de diseño "Singleton".
    private synchronized static void createInstance(){
        if(INSTANCE == null){
          INSTANCE = new StockCountMRG();
        }
    }
    
    public static StockCountMRG getInstance(){
      createInstance();
      return INSTANCE;
    }

No comments:

Post a Comment