Best practice regarding number of threads in GUI applications

后端 未结 9 1303
谎友^
谎友^ 2021-01-19 16:43

In the past I\'ve worked with a number of programmers who have worked exclusively writing GUI applications.

And I\'ve been given the impression that they have almost

9条回答
  •  鱼传尺愫
    2021-01-19 17:26

    Yes.

    GUI applications should minimize the the number of threads that they use for the following reasons:

    1. Thread programming is very hard and complicated
    2. In general, GUI applications do at most 2 things at once : a) Respond to User Input, and b) Perform a background task (such as load in data) in response to a user action or an anticipated user action

    In general therefore, the added complexity of using multiple threads is not justified by the needs of the application.

    There are of course exceptions to the rule.

提交回复
热议问题