标签:nal 加锁 逻辑 ring 实现 对象 写入 oid str
核心是类文件中,使用static修饰的reentrantLock对象
public class SourceCache {
public static final Lock reentrantLock = new ReentrantLock();
/**
* 系统名,devopsdata的映射map
*/
private static Map<String,DevopsData> devopsDataCache;
/**
* 系统名, jonedata的映射map
*/
private static Map<String,JoneData> joneDataCache;
public static Map<String, DevopsData> getDevopsDataCache() {
return devopsDataCache;
}
public static Map<String, JoneData> getJoneDataCache() {
return joneDataCache;
}
public static void setDevopsDataCache(Map<String, DevopsData> devopsDataCache) {
reentrantLock.lock();
try {
SourceCache.devopsDataCache = devopsDataCache;
}finally {
reentrantLock.unlock();
}
}
public static void setJoneDataCache(Map<String, JoneData> joneDataCache) {
reentrantLock.lock();
try {
SourceCache.joneDataCache = joneDataCache;
}finally {
reentrantLock.unlock();
}
}
}
reentrantLock.lock();
try {
SourceCache.joneDataCache = joneDataCache;
}finally {
reentrantLock.unlock();
}
标签:nal 加锁 逻辑 ring 实现 对象 写入 oid str
原文地址:https://www.cnblogs.com/PythonOrg/p/14509925.html