Why is a single threaded model used to update the UI as main thread?
The Qt doc says,
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.
The Android doc says,
Like activities and the other components, services run in the main
thread of the application process
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
Why does they use a single threaded model to update UI ?
Solutions Collect From Internet About “Why is a single threaded model used to update the UI as main thread?”
The short answer is, it’s the only reasonable way to ensure that the display is not corrupted.
The long answer is that allowing multiple threads to update the UI results in deadlocks, race conditions, and all sorts of trouble. This was the painful lesson taught by Java’s AWT (among other UI systems) that allows multiple threads to touch the UI. See, for instance, this blog post.
- image compression by size – iPhone SDK
- Xcode 5 Cocoa App Fails to Load Nib on OS X 10.6
- How to detect default avatar on facebook?
- Swift 3 first parameter names
- Export SQLite data to Excel in iOS programmatically
- iOS Mapkit Custom Callout
- Encoding NSAttributedString Throws Error
- Storing high precision latitude/longitude numbers in iOS Core Data
- Swift use c struct
- How to import a private framework in Xcode 8.3 without getting “Undefined symbols for architecture arm64”
- “loaded nib but the view outlet was not set” exception
- UIActionSheet not showing in iOS 8
- /usr/bin/codesign failed with exit code 1
- embed live camera view inside a UIView
- Reduce pdf size – Objective c