Deadlock sample in .net?

后端 未结 5 1406
清歌不尽
清歌不尽 2020-12-16 18:07

Can anybody give a simple Deadlock sample code in c# ? And please tell the simplest way to find deadlock in your C# code sample. (May be the tool which will detect the dead

5条回答
  •  情书的邮戳
    2020-12-16 18:51

    To answer the part of your question about deadlock detection, I rather doubt that this is in general possible. It is similar in question with the halting problem, you cannot effectively compute the semantics. One way to overcome this is to use a watchdog which would periodically poll each thread if it is still alive and give it a certain timeout to answer, if 2 threads do not respond, you can assume they are either to busy or they are dead-locked.

提交回复
热议问题