synchronized not synchronizing

爱⌒轻易说出口 提交于 2019-12-06 06:04:27

As mentioned in the comments to the question, a thread is capable of reentering its own synchronized lock. The "makeMove()" function call was actually the instigator of calling "move()" which meant it was executing under the same thread and thus not being locked out. In short, the below code would not cause a deadlock; it would execute without a problem and this is what I was experiencing.

synchronized(movementMutex_)
{
    synchronized(movementMutex_)
    {
        doSomething();
    }
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!