Every Android application is started with numerous threads that are bundled with the Linux process and the Dalvik VM to manage the internal execution of the application. But the application is exposed to system threads like the UI and Binder threads, and creates background threads of its own. It is now time to get in under the hood of threading on the Android platform:
All application threads are based on the native
pthreads in Linux with a
Thread representation in Java, but the platform still assigns special properties to threads that make them differ. From an application perspective the thread types are UI, binder, and background threads.
The UI thread is started when the application is started and stays alive during the lifetime of the Linux process. The UI thread is the main thread of the application, used for executing Android components and updating the UI elements on the screen. If the platform detects that UI updates are attempted from any other thread, it will promptly notify the application by throwing a
CalledFromWrongThreadException. This harsh platform behavior is required because the Android UI Toolkit is not thread-safe, so the runtime allows access to the UI elements from one thread only.
UI elements ...