Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between UI Thread and Worker Thread in Android?

Tags:

android

I have read documents about Thread on Android, but I could not find differences between UI thread and Worker Thread. Can someone just give me more example about it?

like image 865
Quang Dai Ngo Avatar asked Aug 07 '15 08:08

Quang Dai Ngo


People also ask

What is difference between UI thread and main thread in Android?

In Android the main thread and the UI thread are one and the same. You can use them interchangeably. In Android each app gets a dedicated process to run. Thus the process will be having a main thread.

What is UI thread in Android?

User Interface Thread or UI-Thread in Android is a Thread element responsible for updating the layout elements of the application implicitly or explicitly. This means, to update an element or change its attributes in the application layout ie the front-end of the application, one can make use of the UI-Thread.

What are main two types of thread in Android?

There're 3 types of thread: Main thread, UI thread and Worker thread. Main thread: when an application is launched, the system creates a thread of execution for the application, called main.

What is a worker thread?

Worker thread is a continuous parallel thread that runs and accepts messages until the time it is explicitly closed or terminated. Messages to a worker thread can be sent from the parent thread or its child worker threads. Through out this document, parent thread is referred as thread where a worker thread is spawned.


1 Answers

The Ui thread is the thread that makes any changes required for the ui.

A worker thread is just another thread where you can do processing that you dont want to interupt any changes happening on the ui thread

If you are doing large amounts of processing on the ui thread while a change to the ui is happening the ui will freeze until what ever you have running complete.

like image 106
Stimsoni Avatar answered Oct 11 '22 11:10

Stimsoni