Overview of Processes and Threads

Learn about processes and threads in Android.

Introduction

In an operating system, a thread refers to the smallest processing task it performs. A process is an instance of a computer program that executes on one or multiple threads. When an Android application starts, the Android operating system creates a process for the application. Components in the application can choose to exist in this process or be a part of another process.

In this lesson, we’ll learn about processes and threads in Android and will understand what we should use and when.

Process

By default, all the components in an application exist as a part of the same process. However, it’s possible to use a different process for certain components by specifying the android:process attribute in the AndroidManifest.xml file.

The Android system decides which processes live by killing certain processes when the system is low on resources. It takes care of recreating the processes if there was a pending task for the killed process. The system uses the priority of the process to decide which ones should continue to live. For example, it’s less likely for an active activity to be killed than one running in the background.

Let’s see how android:process can be used to specify a different process for an activity.

Get hands-on with 1200+ tech skills courses.