Unit testing a multithreaded application?

后端 未结 9 2522
-上瘾入骨i
-上瘾入骨i 2020-11-28 06:03

Does anyone have any advice for a consistent way to unit test a multithreaded application? I have done one application where our mock \"worker threads\" had a thread.sleep

9条回答
  •  长情又很酷
    2020-11-28 06:48

    It's important to test multi-threaded code on a multi-processor machine. A dual-core machine may not be sufficient. I've seen deadlocks occur on a 4 processor machine that did not occur on a dual-core single processor. Then you need to create a stress test based on a client program that spawns many threads and makes multiple requests against the target application. It helps if the client machine is multi-processor as well so there is more load on the target application.

提交回复
热议问题