How to explain the “deadlock” better?

前端 未结 15 915
不知归路
不知归路 2020-12-13 00:52

I am struggling to explain \"deadlock\" in threads in easy words, so please help. What could be the best example of \"deadlock\" (say, in Java), and how it does happen in st

15条回答
  •  时光说笑
    2020-12-13 01:14

    Deadlock happens when you have 2 different resources that 2 different threads need to lock in order to use them. The threads lock them in the opposite order, so it becomes impossible for execution to continue until 1 of the threads backs down.

    Wikipedia has a couple good real-life examples of deadlock.

提交回复
热议问题