I am new to RxJava and fighting for (I think) a simple problem. I want to handle part of a simuleasly subscription in 3 threads. That is why I use FixedThreadPool. Code example:
Observer.just("one", "two", "three", "four")
.observeOn(Schedulers.io())
.subscribeOn(Schedulers.from(Executors.newFixedThreadPool(3))
.subscribe(new Observer<String>() {
public void onNext(String string) {
Log.d(TAG, "Started: " + string);
SystemClock.sleep(1000);
Log.d(TAG, "Ended: " + string);
}
(...)
}
Expected Result:
Started: one
Started: two
Started: three
Ended: one
Started: four
Ended: two
Ended: three
Ended: four
Actual result:
Started: one
Ended: one
Started: two
Ended: two
Started: three
Ended: three
Started: four
Ended: four
What am I doing wrong?
source
share