The SubscribeOn operator changes this behavior by specifying a different Scheduler on which the Observable should operate.
The ObserveOn operator specifies a different Scheduler that the Observable will use to send notifications to its observers.
The SubscribeOn operator designates which thread the Observable will begin operating on, no matter at what point in the chain of operators that operator is called.
ObserveOn, on the other hand, affects the thread that the Observable will use below where that operator appears.
ObserveOn影响其后操作使用的线程
SubscribeOn影响所有操作, 但ObserveOn优先
SubscribeOn在chain中的位置无所谓
多个SubscribeOn,第一个有效
测试代码:
参考http://reactivex.io/documentation/scheduler.html
http://www.grahamlea.com/2014/07/rxjava-threading-examples/
本文详细解析了RxJava中的线程调度机制,包括SubscribeOn和ObserveOn两个关键操作符的作用及区别。通过示例代码说明如何指定观察者接收通知的线程,以及源Observable开始执行的线程。
6402

被折叠的 条评论
为什么被折叠?



