Code Room
Code reviewHard
Question
Review this Java cache that notifies observers under its lock.
What a strong answer looks like
Separate real bugs from style. Rank issues by severity, point at the root cause rather than the symptom, and suggest a concrete fix — specific and kind.
Learn the concepts
public class StateStore { private final Object lock = new Object(); private final Map<String, String> state = new HashMap<>(); private final List<Observer> observers = new ArrayList<>(); public void put(String k, String v) { synchronized (lock) { state.put(k, v); for (Observer o : observers) o.onChange(k, v); } }}Run or narrate your approach, then ask the coach.