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

1 Answer

0 votes

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 Apr 8, 2021 in JAVA by SakshiSharma
+2 votes
asked Feb 8, 2020 in JAVA by rahuljain1
0 votes
asked Jun 26 in Django by john ganales