Android-CleanArchitecture icon indicating copy to clipboard operation
Android-CleanArchitecture copied to clipboard

Cloud and Disk logic executed on Main Thread

Open Goran1708 opened this issue 8 years ago • 2 comments

Not sure if its on purpose but the way you made rxjava with subscribeOn and observeOn doesn't put UserDataStore logic on background Thread. You have to Defer logic to background Thread.

You can check it in this thread. http://stackoverflow.com/questions/29169194/why-does-subscribe-not-executed-in-a-new-thread

Goran1708 avatar Oct 25 '16 15:10 Goran1708

in that SO post, the method is not returning an Observable. However, buildUseCaseObservable method from UseCase class is returning Observable. So, it will execute on background Thread (in this case Schedulers.IO).

aldoKelvianto avatar Dec 09 '16 11:12 aldoKelvianto

@aldoKelvianto but when print enable Strict mode I am getting warning StrictMode policy violation; ~duration=58 ms: android.os.StrictMode$StrictModeDiskReadViolation: policy=65543 violation=2

And I did the print the name of the thread: Log.d("TAG", "Current Thread Name : " + Thread.currentThread().getName());

I am getting "main"

That means disk reading from the main thread.

drayan85 avatar Jan 24 '18 11:01 drayan85