What will happen if thread throws a Exception inside synchronised block

后端 未结 3 1980
北恋
北恋 2021-02-05 18:18

Consider multiple threads are trying to access critical section, what will happen one thread that occurs Exception inside a synchronized block it having wait() and notify() to

3条回答
  •  闹比i
    闹比i (楼主)
    2021-02-05 19:06

    As mentioned if an exception occurs then it should be handled/thrown to continue the execution or else execution will stop. So, it is same in your scenario if an exception happens then it would be handled and further the lock will be released.

提交回复
热议问题