Why is a single threaded model used to update the UI as main thread? Why is a single threaded model used to update the UI as main thread? android android

Why is a single threaded model used to update the UI as main thread?


The short answer is, it's the only reasonable way to ensure that the display is not corrupted.

The long answer is that allowing multiple threads to update the UI results in deadlocks, race conditions, and all sorts of trouble. This was the painful lesson taught by Java's AWT (among other UI systems) that allows multiple threads to touch the UI. See, for instance, Multithreaded toolkits: A failed dream?. That post refers (via dead links) to Why Threads Are A Bad Idea and Threadaches.