Unit test for thread safe-ness?

There are two products that can help you there:

Both check for deadlocks in your code (via unit test) and I think Chess checks for race conditions as well.

Using both tools is easy – you write a simple unit test and the run your code several times and check if deadlocks/race conditions is possible in your code.

Edit:
Google has released a tool that checks for race condition in runtime (not during tests) that called thread-race-test.
it won’t find all of the race conditions because it only analyse the current run and not all of the possible scenarios like the tool above but it might help you find the race condition once it happens.

Update:
Typemock site no longer had a link to Racer, and it was not been updated in the last 4 years. I guess the project was closed.

Leave a Comment