Kristof
Kristof

Reputation: 1704

How does RxJava actually work internally in regards to threading?

I have experience working with RxJava, to make reactive applications. However, I'm wondering how it (and other libraries, like Spring Reactor), actually work on the inside. I can't seem to find any interesting information regarding that online, only the typical simple tutorials. How does it deal with threading, etc? Do all "actors" run on the same thread? Or is it a thread per "declaration"?

Upvotes: 0

Views: 1250

Answers (1)

Chris Mowforth
Chris Mowforth

Reputation: 6723

One key point about RxJava is it allows both the API owner and the consumer to decide on an execution model (and change it without breaking any interfaces). If you want to expose an observable which runs on the calling subscriber thread, inside an ExecutorService, on an Actor, e.t.c, that's up to you. Likewise you can subscribe to an observable using whatever threading model suits- be it blocking on the calling thread or on some kind of thread pool. Bottom line is the library itself takes no opinion on threading model; you need to decide what's best for the workload you're exposing.

Upvotes: 1

Related Questions