I have been developing many softwares using C# .NET and Android. I have noticed that both systems have the same behaviour on Thread
upon UI control
(Label/TextView, etc...). And for that, I don't think it is just coincident for the design to prevent changes outside of thread.
The most popular problem people are having is that they cannot be changed (say, Text
property) outside of the thread they were created. We must either use Invoke
in C#, or use Handler
in Android.
My question is, WHY do controls have to implement such behaviour? What bad may happen if I could change their property/field outside of the thread they were created?
EDIT: Thanks Raghunandanless for your reference. I have already known parts of it, and my main concern for this question is, why thread from a thread pool aren't running on your UI thread cannot access control's properties/fields? The Android's View
are actually just POJO, am I correct? If so, I think any thread can access them with no problem. Please clarify if I said anything wrong.