0 votes
in JAVA by
Why must wait() method be called from the synchronized block?

1 Answer

0 votes
by

We must call the wait method otherwise it will throw java.lang.IllegalMonitorStateException exception. Moreover, we need wait() method for inter-thread communication with notify() and notifyAll(). Therefore It must be present in the synchronized block for the proper and correct communication.

...