filmov
tv
Processes and Threads Overview Tutorial | Android Studio App Development

Показать описание
#AndroidStudioTutorial #Android #AndroidStudioAppDevelopment
What is Process ?
when we have start the application and application doesn't have any components running, The
Android system start a new process for the application with a single thread execution.
by default all android components of the application run in the same process and thread and that
thread we have called Main Thread.
and if the application is already running then the component will be start within that process and
use the same thread of execution.
we have list out android components of the application,
activity
service
receiver
provider
all these above components are run in same process unless you don't define in manifest file.
the manifest entry of each components supports an android:process attribute that can specify a
process in which that components should run. you can set this attribute so that each component
runs its own process or some components share a process while other not.
application element also support android:process attribute to set default value that applies to all
components.
Android System can shutdown a process at some point when memory is low and other process
required.
What is Main Thread ?
when an application is launched the system create a thread of execution for the application called
Main Thread.
Main Thread is the only thread that dispatching event to user interface widgets like drawing event
button click so main thread is also called the UI Thread.
Android system run all components in the same process of UI Thread so all user action and system
call and lifecycle callback method always run in the UI Thread.
When your app perform intensive work in single thread execution then it produce poor
performance.
when you do everything in UI thread like network call , database quires it will block the whole UI. and when UI thread is block then it can't be dispatch event like component drawing event and if UI
thread is block more than 5 seconds then Android system show ANR dialog (application not
responding)
For UI thread use there is two thumb rule
1. DO NOT BLOCK THE UI THREAD
2. DO NOT ACCESS THE UI TOOLKIT FROM THE OUTSIDE THE UI THREAD.
What is Process ?
when we have start the application and application doesn't have any components running, The
Android system start a new process for the application with a single thread execution.
by default all android components of the application run in the same process and thread and that
thread we have called Main Thread.
and if the application is already running then the component will be start within that process and
use the same thread of execution.
we have list out android components of the application,
activity
service
receiver
provider
all these above components are run in same process unless you don't define in manifest file.
the manifest entry of each components supports an android:process attribute that can specify a
process in which that components should run. you can set this attribute so that each component
runs its own process or some components share a process while other not.
application element also support android:process attribute to set default value that applies to all
components.
Android System can shutdown a process at some point when memory is low and other process
required.
What is Main Thread ?
when an application is launched the system create a thread of execution for the application called
Main Thread.
Main Thread is the only thread that dispatching event to user interface widgets like drawing event
button click so main thread is also called the UI Thread.
Android system run all components in the same process of UI Thread so all user action and system
call and lifecycle callback method always run in the UI Thread.
When your app perform intensive work in single thread execution then it produce poor
performance.
when you do everything in UI thread like network call , database quires it will block the whole UI. and when UI thread is block then it can't be dispatch event like component drawing event and if UI
thread is block more than 5 seconds then Android system show ANR dialog (application not
responding)
For UI thread use there is two thumb rule
1. DO NOT BLOCK THE UI THREAD
2. DO NOT ACCESS THE UI TOOLKIT FROM THE OUTSIDE THE UI THREAD.