public class Cache {
private Map cache = new HashMap() ;
public Object get(String key) {
return cache.get(key);
}
public void reload(){
Map tempCache = loadFromDB();
cache = tempCache; // safe ?
}
}
一个朋友给我发的,问我线程安全么?
转载于:https://my.oschina.net/xishuixixia/blog/141764