How to discover multi threading related bugs and debug them?

Multi threaded applications are great, they provide high performance, high throughput but tackling concurrency issues are sometimes  not easy. Especially preemption related bug cannot be easily reproduced. Thus Microsoft created a useful tool called CHESS, to simulate all possible preemptions for your multi threaded application.

How to correctly implement multi-threading in C#
http://csharptest.net/323/how-to-correctly-implement-multi-threading-in-c/

Tools And Techniques to Identify Concurrency Issues
http://msdn.microsoft.com/en-us/magazine/cc546569.aspx

 

Custom Trace Listener and multiple threads
http://woodoweb.com/index_files/c19ae1908f273cdfe9dc2c8f2a82e202-26.html

 

CHESS: Systematic Concurrency Testing

CHESS is a tool for systematic and disciplined concurrency testing. Given a concurrent test, CHESS systematically enumerates the possible thread schedules to find hard-to-find concurrency errors, including assertion violations, deadlocks, data-races, and atomicity violations.
ref: http://chesstool.codeplex.com/

CHESS: An Automated Concurrency Testing Tool
http://channel9.msdn.com/shows/Going+Deep/CHESS-An-Automated-Concurrency-Testing-Tool/

CHESS: Find and Reproduce Heisenbugs in Concurrent Programs
http://research.microsoft.com/en-us/projects/chess/

CHESS: An Automated Concurrency Testing Tool
http://channel9.msdn.com/shows/Going+Deep/CHESS-An-Automated-Concurrency-Testing-Tool/

 

 

Unit Testing Asynchronous Code: Three Solutions for Better Tests
https://msdn.microsoft.com/en-us/magazine/dn818494.aspx

Improved Multithreaded Unit Testing
http://mir.cs.illinois.edu/gliga/papers/JagannathETAL11IMunit.pdf