public class Cache {
Map<Object, Object> cache = new ConcurrentHashMap<Object, Object>();
public Object get(Object key) {
Object value = cache.get(key);
if(value == null) {
synchronized (cache) {
value = cache.get(key);
if(value == null) {
value = load(key);
cache.put(key, value);
}
}
}
return value;
}
}