当我分析应用程序时,我有使用Solr 4的遗留Java应用程序 使用分析器,我看到在LRUcache get / put上阻塞了所有线程 当我检查Solr LRUcache源代码时,我可以看到put / get都是 同步
例如: PUT
@Override
public V put(K key, V value) {
synchronized (map) {
if (getState() == State.LIVE) {
stats.inserts.increment();
}
GET
@Override
public V get(K key) {
synchronized (map) {
V val = map.get(key);
if (getState() == State.LIVE) {
// only increment lookups and hits if we are live.
lookups++;
stats.lookups.increment();
if (val!=null) {
hits++;
stats.hits.increment();
}
}
return val;
}
}
我的问题是如何微调它以免在此部分代码中被阻止?