RxJava:当 "The Observable Contract" 说 "happens-before" 时,它实际上是什么意思?
RxJava: When "The Observable Contract" says "happens-before", what does it actually mean?
Observables must issue notifications to observers serially (not in parallel). They may issue these notifications from different threads, but there must be a formal happens-before relationship between the notifications.
当它说“happens-before”时,是否意味着最后一个 onNext 通知的所有效果(例如,在 Observer.onNext() 方法中更改共享状态)将完全可见next onNext 通知,就像 happens-before 保证在 Java 内存模型?
看了SerializedObserver(RxJava version 3.0.11)的源码,发现synchronized代码块中没有调用downstream.onNext(t)方法。那么,我能说答案不是吗?
will be totally visible to the next onNext notification, just like happens-before guarantee in Java Memory Model?
是的。
SerializedObserver [...] I found downstream.onNext(t) method is not called in the synchronized code block. So, could I say the answer is not?
还是。 synchronized (this) 确保可见性以及 属性 由于 emitting
标志,只有一个线程将调用 onNext
。
Observables must issue notifications to observers serially (not in parallel). They may issue these notifications from different threads, but there must be a formal happens-before relationship between the notifications.
当它说“happens-before”时,是否意味着最后一个 onNext 通知的所有效果(例如,在 Observer.onNext() 方法中更改共享状态)将完全可见next onNext 通知,就像 happens-before 保证在 Java 内存模型?
看了SerializedObserver(RxJava version 3.0.11)的源码,发现synchronized代码块中没有调用downstream.onNext(t)方法。那么,我能说答案不是吗?
will be totally visible to the next onNext notification, just like happens-before guarantee in Java Memory Model?
是的。
SerializedObserver [...] I found downstream.onNext(t) method is not called in the synchronized code block. So, could I say the answer is not?
还是。 synchronized (this) 确保可见性以及 属性 由于 emitting
标志,只有一个线程将调用 onNext
。