What is an example of when a deadlock is ben开发者_如何学编程eficial?
If the program you're deadlocking is a virus?
If you want to freeze up a process, I suppose that would be the only time you should do it... lol.
It's beneficial in that it clearly demonstrates you that your code is buggy and your synchronization methods need to be revised.
here is an example of exploiting a db deadlock in mysql. It's more of a hack than a generalizable benefit of deadlocks, but it's the only thing I've ever come across that involves creating a deadlock for a beneficial effect other than for training purposes and for testing automated detection methods (which some may argue are both beneficial but where the benefit comes from helping avoid future deadlocks, so they are beneficial in the same sense as it's beneficial to study a deadly disease in a lab).
A deadlock is never beneficial. It is a huge problem in a program, because it causes the program to freeze under given circumstances!
A deadlock is never beneficial. It occurs when one or more processes are blocked forever because of requirements that cannot be satisfied. This will usually cause the program to appear to freeze as the processes will not continue unless the deadlock is broken. Programs must be crafted specifically to avoid deadlocks in all cases.
精彩评论