Deadlock sample in .net?
问题 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 lock in the given sample code.) NOTE: I have VS 2008 回答1: one common way is if you have nested locks that aren't acquired in the same order. Thread 1 could acquire lock A and thread 2 could acquire lock B and they would deadlock. var a = new object(); var b = new object(); lock(a) { lock(b) { } } // other thread lock (b) {