Why Java’s wait() Must Be Called Inside a synchronized Block
Because wait() first releases the monitor, the calling thread must own the lock; the JVM enforces this with an IllegalMonitorStateException, and the synchronized block prevents the lost‑wake‑up race by atomically checking conditions and releasing the lock before waiting.
