我有以下的代码片段:
public class Example {
private Integer threshold;
private Map<String, Progress> history;
protected void activate(ComponentContext ctx) {
this.history = Collections.synchronizedMap(new LinkedHashMap<String, Progress>() {
@Override
protected boolean removeEldestEntry(Map.Entry<String, Progress> entry) {
return size() > threshold;
}
});
}
}
匿名LinkedHashMap
类和Example
类之间存在循环依赖关系。这样可以吗?为什么不行?它会被垃圾收集器良好回收吗?