Code Room
Code reviewHard
Question
Review this Java latch used by a coordinator to wait until a result is ready.
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
class ResultGate { private final Object lock = new Object(); private boolean ready = false; private Object value; void publish(Object v) { value = v; synchronized (lock) { ready = true; lock.notify(); } } Object await() throws InterruptedException { synchronized (lock) { if (!ready) lock.wait(); return value; } }}Run or narrate your approach, then ask the coach.