Do small Calculation Task in Background Using RxJava in Most Efficient Way

If you want to use RxJava you get to leverage non-blocking by composing multiple operations in Observables. There are plenty of tutorials out there to help. To answer your question though using RxJava 1:

    .fromRunnable(() -> doSomething())
    .doOnError(e -> log.error(e.getMessage(), e))

If doSomething doesn’t use CPU exclusively then you might choose instead of Schedulers.computation().

Leave a Comment