How to use wait and notify in Java without IllegalMonitorStateException? How to use wait and notify in Java without IllegalMonitorStateException? multithreading multithreading