RxJava
RxJava – Reactive Extensions for the JVM – a library for composing asynchronous and event-based programs using observable sequences for the Java VM.
RxJava: reactive streams on the JVM
A Java VM implementation of Reactive Extensions for composing asynchronous and event-based programs with observable sequences. The README covers the base types, schedulers, and what the 4.0 release is promising.
The idea
RxJava is a Java VM implementation of Reactive Extensions, a library for composing asynchronous and event-based programs by using observable sequences. It extends the observer pattern to support sequences of data and events, and adds operators that let you compose sequences declaratively while abstracting away low-level threading, synchronization, thread safety, and concurrent data structures.
The 4.0 story
The README tracks a 4.0.0 release. The highlighted changes include a native Java 26 implementation, no third party library required at runtime, JPMS and OSGi support kept intact, a java.util.concurrent.Flow-based implementation, and virtual thread support through methods like virtualCreate and virtualTransform plus a Schedulers.virtual. A new Streamable type is built around virtual threads and virtual blocking. The notes also say RxJava 3.x support will be toned down in the coming months and offered for over a year after the 4.x official release.
The base types
The base classes live under io.reactivex.rxjava4.core. Flowable handles 0 to N flows with backpressure, Observable handles 0 to N flows without backpressure, Single is a flow of exactly one item or an error, Completable has no items and only a completion or error signal, and Maybe covers no items, one item, or an error. Streamable is new, based on virtual blocking and CompletionStage state machines with native backpressure. The terminology section defines upstream as looking toward the source and downstream as looking toward the consumer, and treats emission, item, event, signal, data, and message as synonyms.
Moving work between threads
Operators work with Schedulers rather than threads directly. The standard set includes computation for CPU-bound work, cached for IO-like or blocking work, virtual for scatter-gather with virtualized stacks, single, and trampoline, plus platform schedulers like AndroidSchedulers.mainThread, SwingScheduler, and JavaFXScheduler. The typical pattern is subscribeOn to move computation or blocking IO to another thread and observeOn to process results on the foreground or GUI thread. One note catches people out: default schedulers run on daemon threads, so when the main thread exits, background work stops, which is why the README's example sleeps for a bit before finishing.
Editorial conclusion
For a library this old, the README spends most of its energy on the coming 4.x changes and on explaining backpressure, which is where most newcomers get lost.
Community notes