7

I want to know if all activities in an Android app are run in same thread or separate threads of their own?

ThinkingStiff
  • 64,767
  • 30
  • 146
  • 239
binW
  • 13,220
  • 11
  • 56
  • 69

2 Answers2

14

All activities of one application all run on the same "main" thread, also called "UI-thread". But you can change this behaviour by setting a process attribute in the actvity tag in the manifest file. See http://developer.android.com/guide/topics/manifest/activity-element.html#proc

Olegas
  • 10,349
  • 8
  • 51
  • 72
  • 2
    Also all services, and broadcast receivers are running in one "main" thread. – inazaruk May 24 '11 at 18:26
  • 1
    Technically speaking you wouldn't call the "main" thread the "UI-thread" if an app had no UI elements, ie, Activities. It is possible for an app to simply consist of services, broadcast receivers etc. – Squonk May 24 '11 at 18:34
2

For a detailed explanation read this...Processes and Threads

A quote from it...

When an application component starts and the application does not have any other components running, the Android system starts a new Linux process for the application with a single thread of execution. By default, all components of the same application run in the same process and thread (called the "main" thread). If an application component starts and there already exists a process for that application (because another component from the application exists), then the component is started within that process and uses the same thread of execution. However, you can arrange for different components in your application to run in separate processes, and you can create additional threads for any process.

Squonk
  • 48,735
  • 19
  • 103
  • 135