A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/ReactiveX/RxJava/issues/6447 below:

observeOn.concatMap may not invoke the mapper function on the desired thread · Issue #6447 · ReactiveX/RxJava · GitHub

There are two effects in play here: fusion and trampolining.

Fusion will take the observeOn queue and just pull on it when the subscription happens. Trampolining will use the last interacting thread (the subscription thread or the termination thread) to pull on the internal queue (dedicated or fused) and when there is an item, it will run the mapper on that thread.

Flowable.range(1, 5)
    .observeOn(Schedulers.computation())
    .concatMap(v -> Flowable.just(Thread.currentThread().toString()))
    .blockingSubscribe(System.out::println);

This will likely print computation, main, main, main, main.

Workarounds:

Appeared on StackOverflow.

kojilin, hirakida and KarboniteKream


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4