Can we use deadlocks?

I was wondering about this. Deadlocks are something we prefer to avoid, but is there any scenario in which we can use deadlocks to our advantage?

+3


source to share


2 answers


A deadlock is a situation where two or more competing actions are waiting for another, and, does.

enter image description here

So your goal is not to fall into it. If your code is deadlocked, then you need to go back and re-design your code to avoid / minimize such deadlocks. It would also be nice to have some kind of recovery mechanism and warning when you get stuck.



Now for your question: can this be used for something? Well, there is always a good use, because something depends on your situation and your goal. Here are some scenarios:

  • If you are a hacker trying to attack an application, you can freeze the system, forcing it into many dead ends.
  • If you are the developer of any deadlock detection system, you want to create such deadlocks in a test environment to make sure it gets caught by your system or not.
+2


source


NOT!

Deadlock puts your code in a state where nothing can continue.



(Warning, snarky comment: if that's what you want, just don't run the code).

+1


source







All Articles