+ 2
multi-threading in android
why in Android os, a thread can't access to UI thread and we should use message, handler, runOnUi, or something like? in Java does not exist this issue. So why it appears in Android API? Also explain how handler and runOnUi solve this problem?What techniques or codes do they use within themselves?
1 Odpowiedź
+ 2
Apps on Android phones perform far better with multiple threads and very little done on the main UI thread because smart phones and tablets have many weak CPU cores instead of fewer but stronger CPU cores like on a full size desktop.
There are more details on why multithreading is encouraged and forced in Android development here:
https://developer.android.com/topic/performance/threads
You might also want to look at this comparison between a few ways to run code in the UI thread:
https://stackoverflow.com/questions/12850143/android-basics-running-code-in-the-ui-thread