Why is my multi-threading slower than my single threading?

后端 未结 6 1695

I know a couple of people asked a question similar to this, but I can’t find any response that would make me understand why it\'s slower.

So, I made a little console

6条回答
  •  清歌不尽
    2020-12-14 07:09

    If you delete line below, your multithread would be faster.

    Console.Write(procName);
    

    its because the operating system treat Console as a shared resource and just one thread can use a shared resource at a moment.So in this condition, mutlithread speed up would be like a single thread, but multithreading is burdening some additional thread management overhead with no performance gain.

提交回复
热议问题