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

后端 未结 9 1100
生来不讨喜
生来不讨喜 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:53

    You should use multithreading when you want to perform heavy operations without "blocking" the flow.
    Example in UIs where you do a heavy processing in a background thread but the UI is still active.

    If the threads execute mutually exclusive tasks it is the best since there is no overhead for synchronization among threads needed

提交回复
热议问题