Deadlock sample in .net?

后端 未结 5 1403
清歌不尽
清歌不尽 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:58

    For the deadlock sample code, try using lock(this) in your class to simulate the deadlock scenario. Checkout this example.

    Following two worthy reading articles detects the deadlock at runtime and discusses ways to avoid them.

    1. Deadlock monitor by Stephen Toub.
    2. TimedLock Again by Ian Griffiths.

提交回复
热议问题