private static IDictionary<string, ClassMap> cache = new Dictionary<string, ClassMap>();
public static void Add(string key, ClassMap map)
{
if (!cache.Keys.Contains(key))
{
cache.Add(key, map);
}
}
Exception:
The index is outside boundary of arrangement.
public static void Add(string key, ClassMap map)
{
if (!cache.Keys.Contains(key))
{
cache.Add(key, map);
}
}
Exception:
The index is outside boundary of arrangement.
cache字段加volatile关键字表示可能被多个并发执行线程修改
或者访问cache字段代码放在lock语句块中标记为临界区,互斥访问