June 2017
Intermediate to advanced
400 pages
8h 44m
English
IO tasks such as reading and writing databases, web requests, and disk storage are less expensive on the CPU and often have idle time waiting for the data to be sent or come back. This means you can create threads more liberally, and Schedulers.io() is appropriate for this. It will maintain as many threads as there are tasks and will dynamically grow, cache, and reduce the number of threads as needed. For instance, you may use Schedulers.io() to perform SQL operations using RxJava-JDBC (https://github.com/davidmoten/rxjava-jdbc):
Database db = Database.from(conn); Observable<String> customerNames = db.select("SELECT NAME FROM CUSTOMER") .getAs(String.class) .subscribeOn(Schedulers.io());
But you have to be careful! As a rule of thumb, ...
Read now
Unlock full access