Schedulers are used in multi-threading environment to work with Observable operators.
As per the Reactive,Scheduler are used to schedule how chain of operators will apply to different threads.
By default, an Observable and the chain of operators that you apply to it will do its work, and will notify its observers, on the same thread on which its Subscribe method is called. The SubscribeOn operator changes this behavior by specifying a different Scheduler on which the Observable should operate. The ObserveOn operator specifies a different Scheduler that the Observable will use to send notifications to its observers.
There are following types of Schedulers available in RxJava −
|Sr.No.||Scheduler & Description|
Creates and returns a Scheduler intended for computational work. Count of threads to be scheduled depends upon the CPUs present in the system. One thread is allowed per CPU. Best for event-loops or callback operations.
Creates and returns a Scheduler intended for IO-bound work. Thread pool may extend as needed.
Creates and returns a Scheduler that creates a new Thread for each unit of work.
Creates and returns a Scheduler that queues work on the current thread to be executed after the current work completes.
Converts an Executor into a new Scheduler instance.