The schedulers are the RxJava's way of achieving concurrency. They are in charge of creating and managing the threads for us (internally relying on Java's threadpool facilities). We won't be dealing with Java's concurrency API and its quirks and complexities. We've been using the schedulers all along, implicitly with timers and intervals, but the time has come to master them.
Let's recall the
Observable.interval factory method, which we introduced back in Chapter 3, Creating and Connecting Observables, Observers, and Subjects. As we saw before, RxJava is single-threaded by default, so in most cases, calling the
subscribe method on the
Observable instance will block the current thread. But that is not the case with the
interval Observable instances. If we look at the JavaDoc of the
Observable<Long> interval(long interval, TimeUnit unit) method, we'll see that it says that the
Observable instance created by it operates on something called 'the computation Scheduler...