In an Android app with multiple Activities, is each activity's UI thread a separate thread or are they actually the same thread (like a global, per app UI thread)?
It is also almost always the thread in which your application interacts with components from the Android UI toolkit (components from the android. widget and android. view packages). As such, the main thread is also sometimes called the UI thread.
So is an activity is an independent thread? Yes and no. An Android app with one Activity will have a single process and single thread but if there are multiple app components they will normally all use the same thread (except for certain Android classes which use their own threads to do work).
Concurrency means running multiple tasks in parallel, it is one of the main reasons that we use threads. As Android is a single-threaded model, we need to create different threads to perform our task and post the result to the main thread where the UI gets updated.
Developers multithread Android applications in order to improve their performance and usability. By spinning off processor- or resource-intensive tasks into their own threads, the rest of the program can continue to operate while these processor intensive tasks finish working.
Each application has one UI thread, which is used to run whichever Activity is in the foreground.
There is some more information here:
http://developer.android.com/guide/topics/fundamentals/processes-and-threads.html
http://android-developers.blogspot.co.il/2009/05/painless-threading.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With