- RxJava - Discussion
- RxJava - Useful Resources
- RxJava - Quick Guide
- RxJava - Windowing
- RxJava - Buffering
- RxJava - From Scheduler
- RxJava - IO Scheduler
- RxJava - Computation Scheduler
- RxJava - NewThread Scheduler
- RxJava - Trampoline Scheduler
- RxJava - Schedulers
- RxJava - AsyncSubject
- RxJava - ReplaySubject
- RxJava - BehaviorSubject
- RxJava - PublishSubject
- RxJava - Subjects
- RxJava - Connectable Operators
- RxJava - Mathematical Operators
- RxJava - Conditional Operators
- RxJava - Utility Operators
- RxJava - Combining Operators
- RxJava - Filtering Operators
- RxJava - Transforming Operators
- RxJava - Creating Operators
- RxJava - Using CompositeDisposable
- RxJava - Completable Observable
- RxJava - MayBe Observable
- RxJava - Single Observable
- RxJava - Creating Observables
- RxJava - How Observable works
- RxJava - Environment Setup
- RxJava - Overview
- RxJava - Home
Selected Reading
- Who is Who
- Computer Glossary
- HR Interview Questions
- Effective Resume Writing
- Questions and Answers
- UPSC IAS Exams Notes
RxJava - Schedulers
Schedulers are used in multi-threading environment to work with Observable operators.
As per the
,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 |
---|---|
1 | Schedulers.computation() 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. |
2 | Schedulers.io() Creates and returns a Scheduler intended for IO-bound work. Thread pool may extend as needed. |
3 | Schedulers.newThread() Creates and returns a Scheduler that creates a new Thread for each unit of work. |
4 | Schedulers.trampopne() Creates and returns a Scheduler that queues work on the current thread to be executed after the current work completes. |
4 | Schedulers.from(java.util.concurrent.Executor executor) Converts an Executor into a new Scheduler instance. |