Every Android application should adhere to the multithreaded programming model built-in to the Java language. With multithreading comes improvements to performance and responsiveness that is required for a great user experience, but it is accompanied with increased complexities:
Software programming is all about instructing the hardware to perform an action—e.g. show images on a monitor, store data on the file system, etc. The instructions are defined by the application code that the CPU processes in an ordered sequence, which is the high level definition of a thread. From an application perspective a thread is execution along a code path of Java statements that is executed sequentially. A code path that is sequentially executed on a thread is referred to as a task — a unit of work that coherently executes on one thread. A thread can either execute one or multiple tasks in sequence.
A thread in an Android application is represented by
java.lang.Thread. It is the most basic execution environment in Android, that executes tasks when it starts and terminates when the task is finished or there are no more tasks to execute; the alive time of the thread is determined by the length of the task.
Thread supports execution of tasks that are implementions of the
java.lang.Runnable interface. ...