I have following snippet of code:
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;
}
});
}
}
Theres is a cyclic dependency between anonymous LinkedHashMap
class and Example
class. Is this OK or not? Why not? Is it going to be nicely reclaimed by garbage collector?