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.

Related questions

0 votes
asked Jul 24, 2023 in Design Patterns by SakshiSharma
0 votes
asked Jul 23, 2020 in IONIC by Hodge
...