Code example for ConcurrentHashMap

Methods: get, isEmpty, size

0
		} 
		return instance;
	} 
	public SimulatorAdapter getSimulator(byte dimensions){
		try{ 
			if(available.isEmpty()){
				SimulatorAdapter someSim=
					(SimulatorAdapter)Class.forName("simulator.adapters.Adapter"
					+dimensions+"D").newInstance();
				return someSim;
			} 
			return available.get(new Integer(available.size()-1));
		} 
		catch(Exception e){
			System.out.println(e);
			return null; 
		} 
	} 
	public synchronized void returnToFactory(SimulatorAdapter adapter){
		available.put(available.size()-1, adapter);
	}