What to avoid for performance reasons in multithreaded code?

后端 未结 12 2471
执笔经年
执笔经年 2021-02-09 10:45

I\'m currently reviewing/refactoring a multithreaded application which is supposed to be multithreaded in order to be able to use all the available cores and theoretically deliv

12条回答
  •  面向向阳花
    2021-02-09 11:29

    More threads then there are cores, typically means that the program is not performing optimally.

    So a program which spawns loads of threads usually is not designed in the best fashion. A good example of this practice are the classic Socket examples where every incoming connection got it's own thread to handle of the connection. It is a very non scalable way to do things. The more threads there are, the more time the OS will have to use for context switching between threads.

提交回复
热议问题