Skip to content Skip to sidebar Skip to footer

Why Does Looper.loop() Not Block The Ui Thread

This is the code in ActivityThread.main(): public static void main(String[] args) { ...... Looper.prepareMainLooper(); ... Looper.loop();

Solution 1:

Looper.loop() prepares the Looper to run the messages that are passed to the thread.

It doesn't blindly keep iterating over itself, rather it uses a MessageQueue to listen for messages and runs them.

It's an event driven methodology, where the Looper is prepared to loop and run the messages when the MessageQueue notifies it that it contains messages. To know more about how android event loop works, take a look at this article. Looper.looop()

(source)

Post a Comment for "Why Does Looper.loop() Not Block The Ui Thread"