public static synchronized Cache createCache(){
  if (cache == null) {
    Properties dsp=new Properties();
    dsp.setProperty(MCAST_PORT,"0");
    dsp.setProperty(LOCATORS,"");
    DistributedSystem sys=DistributedSystem.connect(dsp);
    try {
      cache=CacheFactory.create(sys);
    }
 catch (    CacheExistsException exp) {
      cache=CacheFactory.getInstance(sys);
    }
catch (    RegionExistsException rex) {
      cache=CacheFactory.getInstance(sys);
    }
  }
  return cache;
}

public static synchronized Cache createCache ( ) { if ( cache == null ) { Properties dsp = new Properties ( ) ; dsp . setProperty ( MCAST_PORT , "0" ) ; dsp . setProperty ( LOCATORS , "" ) ; DistributedSystem sys = DistributedSystem . connect ( dsp ) ; try { cache = CacheFactory . create ( sys ) ; } catch ( CacheExistsException exp ) { cache = CacheFactory . getInstance ( sys ) ; } catch ( RegionExistsException rex ) { cache = CacheFactory . getInstance ( sys ) ; } } return cache ; }
this method creates cache . the cache created is a loner , so this is only suitable for single vm tests .
