I am a beginner in Android data binding.In mvvm Architecture patter when we write code in viewmodel.In which thread those are running in main thread or seperate thread.
You can check using Thread.currentThread()
method
In onCreate Method of Activity put log
Log.d(TAG, Thread.currentThread());
In constructor of Viewmodel put another log
Log.d(TAG, Thread.currentThread());
You will see the same thread Id. Another example is when you try to perform db or network operation in viewmodel without using AsyncTask, Thread or RxJava it throw an Exception that Cannot perform operation on MainThread.
I hope this will help you
Viewmodel is Lifecycle aware class which is associated with UI. So the answer is Main UI Thread.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With