What is an example of unforeseen consequences that Observable.merge <'T> is not thread safe?

The documentation states:

"For each observer, a registered intermediate observation object is not thread safe, that is, observations arising from sources should not be launched simultaneously on different threads."

This also applies to Observable.pairwise<'T> and Observable.scan<'U,'T> .

What is an example of using Observable.merge in a way that creates unintended consequences, given that it is not thread safe?

+4
source share
2 answers

Based on the source code , it looks like the observers should have fired OnCompleted on different threads, then it is possible that the combined observable will not end.

+2
source

Generally speaking, thread safety indicates that using functionality from different threads will not lead to race conditions or deadlocks. In this particular case, I am going to assume that the observations can overwrite each other or otherwise alternate the execution in a way that could cause a crash or other unstable state.

0
source

Source: https://habr.com/ru/post/1501341/


All Articles