private Shard getShard(String schema, String table){
String key = (schema + table).intern();
if (!shards.containsKey(key)){
synchronized (key){
if (!shards.containsKey(key)){
shards.put(key, new Shard(schema, table));
}
}
}
return shards.get(key);
}
根据表名存放数据簇。利用intern得到string的字符串常量区地址,对该地址synchronized减小锁冲突。