When should you use multithreading? And would multi threading be beneficial if the different threads execute mutually independent tasks?

后端 未结 9 1131
生来不讨喜
生来不讨喜 2020-12-23 09:06

This were the only two questions I couldn\'t answer in the interview I got rejected from last night.

9条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-23 09:50

    You should definitely use multithreading in GUI applications when you invoke time consuming tasks from the main event loop. Same applies for server application that might block while doing the I/O.

    For the second question, it is usually yes when you have machine with multiple CPU cores. In this case these independent tasks can be executed in parallel.

提交回复
热议问题