ReentrantLock doesn't work out

前端 未结 1 507
遇见更好的自我
遇见更好的自我 2021-01-25 10:28

I can\'t figure out why the code doesn\'t work properly. The problem is that ReentrantLock doesn\'t lock methods invocation in ThreadClass.run()

Resource-class w

相关标签:
1条回答
  • 2021-01-25 10:57

    You are creating a new ReentrantLock per runnable meaning there is no synchronization. You will need to share the one lock with each Runnable instance.

    0 讨论(0)
提交回复
热议问题