Qt doc说,
As mentioned,each program has one thread when it is started. This
thread is called the “main thread” (also known as the “GUI thread” in
Qt applications). The Qt GUI must run in this thread.
Android文档说,
Like activities and the other components,services run in the main
thread of the application process
而iOS,
It is strongly recommended not to update UI controls etc from a
background thread (e.g. a timer,comms etc). This can be the cause of
crashes which are sometimes very hard to identify. Instead use these
to force code to be executed on the UI thread (which is always the
“main” thread).
为什么他们使用单线程模型来更新UI?
解决方法
简单的答案是,确保显示没有损坏是唯一合理的方法.
最长的答案是允许多个线程更新UI会导致死锁,竞争条件和各种麻烦.这是Java AWT(其他UI系统)教授的令人痛苦的教训,允许多个线程触摸UI.参见,例如,this blog post.