Side effects of throwing an exception inside a synchronized clause?

前端 未结 2 593
無奈伤痛
無奈伤痛 2020-12-01 11:41

Are there any unclear side effects to throwing an exception from within a synchronized clause? What happens to the lock?

private void doSomething() throws E         


        
2条回答
  •  抹茶落季
    2020-12-01 12:07

    I see no side-effect.

    The lock is guaranteed to be terminated in all cases, and an exception is no exception (pun intended).

提交回复
热议问题