Android में एक सख्त threading model है जो main (UI) thread के इर्द-गिर्द केंद्रित है — जिसे UI को संभालना होगा और responsive रहना होगा। Threading, कार्य को main thread से क्यों हटाना चाहिए, और tools (coroutines, और ऐतिहासिक रूप से threads/handlers) को समझना responsive ऐप्स के लिए महत्वपूर्ण है।
Main thread नियम
Android has a single MAIN (UI) thread that:
→ handles ALL UI operations (drawing, events) — UI updates MUST happen on it
→ must stay RESPONSIVE — blocking it freezes the UI; >5s blocked = ANR (App Not Responding)
TWO key rules:
1. DON'T do long/blocking work on the main thread (network, DB, heavy compute) → move it off
2. DON'T update UI from a background thread → switch back to the main thread for UI
