Deadlocks and Synchronized methods

前端 未结 3 1042
太阳男子
太阳男子 2020-12-11 06:36

I\'ve found one of the code on Stack Overflow and I thought it is pretty similar to what I am facing but I still don\'t understand why this would enter a deadlock. The examp

3条回答
  •  忘掉有多难
    2020-12-11 07:08

    Calling methodA does (effectively) lock(a), lock(b). If the task switches then and tries methodB, it hits lock(b) right then.

提交回复
热议问题