The essence of the problem is this: I have Observable and Subscriber . Observable I try to run in the io() stream, as it works with files (I will not show the code, it is quite large, but does not matter), but it does nothing:

  Observable<Double> creatingObservable = getCreatingObservable(image); Subscriber<Double> creatingSubscriber = getCreatingSubscriber(); creatingObservable .subscribeOn(Schedulers.io()) .subscribe(creatingSubscriber); 

If you run the code without subscribeOn , everything works fine. So what is the problem and how to fix it?


PS I still have System.out.println() not working. The problem applies to all Scheduler'a threads.

  • What makes you think that the problem is not in the code that you decided not to show? In the code you cited, the problem is nowhere to come from, so that it is most likely inside getCreatingObservable . - xkor
  • And about System.out.println() - do not use it on the android. On the android for logging it is better to use the built-in class Log , or some third-party type of Timber - xkor
  • @xkor, oh, I accidentally added Android , out of habit. And the problem is not in the creation code, I created it through the usual create . And at enSO they helped solve the problem, it was incredibly banal ... - user189127
  • @ bukashka101, it will not be superfluous if you add links to en-SO to the question / answer) - Yuriy SPb
  • one
    @ YuriySPb, added :) - user189127

1 answer 1

The problem was that the main thread did not wait until the end of the execution of the RxJava'вского stream. As a result, RxJava did not even have time to "squeak" - from here there are no messages from System.out.println() and work with files.


The solution suggested here - https://stackoverflow.com/questions/37993371/rxjava-doesnt-work-in-scheduler-io-thread