Unit test for thread safe-ness?

后端 未结 9 1784
你的背包
你的背包 2020-11-30 19:32

I\'ve written a class and many unit test, but I did not make it thread safe. Now, I want to make the class thread safe, but to prove it and use TDD, I want to write some fa

9条回答
  •  长情又很酷
    2020-11-30 20:06

    The problem is that most of the multi-threading issues, like race conditions, are non-deterministic by their nature. They can depend on hardware behavior which you can't possibly emulate or trigger.

    That means, even if you make tests with multiple threads, they will not be consistently failing if you have a defect in your code.

提交回复
热议问题