Should I worry about the difference between the main thread and the user interface thread in Lollipop and beyond?

Before Lollipop, life was easy. You had a main thread - sometimes also called a UI thread - in which all GUI files were made (and which you avoided under any circumstances for lengthy operations to avoid any hiccups), and you had background threads where you made this very promising one material.

Now in Lollipop and later versions of Android IIRC, the term UI thread seems to indicate to the user a new RenderThread , a thread that, for example, is used to animate ripples, hero elements between actions, or any other kind of animation that should happen when the main thread processes input events or busy creating new material for you in the background.

In Android Studio 1.3, all three types of streams now have their own annotation to indicate that a particular piece of code should work on that particular stream. The question for me now is: should I, as an application developer, run something on UIThread , i.e. RenderThread , and as such use @UIThread in my application?

+7
java android multithreading android-5.0-lollipop
source share
2 answers

I remember the presentation of the Chet Haase RenderThread from last year's Google IO. His statement was that, first of all, we should continue with MainThread , as before. RenderThread used only for animations. For example, if we have a method such as drawing animation onDrawFrame() at a smooth 60 frames per second, we should rather call it in RenderThread , because MainThread can be slowed down using application logic or other material.

Let's get back to your question. I would say using MainThread as before. If you have some performance issues with animation, try moving the drawing parts of your code to RendererThread .

+2
source share

UIThread is still the main thread for your application. Although RenderThread is just a support processing thread that helps your application when there are delays in the main user interface thread. As stated on developer.android.com:

" RenderThread is a new system-driven processing thread that supports animation smoothly, even if there are delays in the main user interface thread."

For your question, if you want to run something on UIThread ? Answer: yes, should RenderThread be used RenderThread ? If possible, yes.

+3
source share

All Articles