NewThread

NewThread is a Scheduler (created by calling Schedulers.newThread()) where things are finally starting to get interesting. What it does is to create a new thread for each Observable when it becomes active, simple as that.

Basically, NewThread can be used anywhere whenever there is a need to offload computation from the current (main) thread. However, creating a new thread for each Observable can be costly in the long run, as thread creation is a relatively heavyweight operation and there are other Schedulers that might be better suited for computation offloading.

One thing to keep in mind is that this Scheduler doesn't place any limits on the number of threads that will be created. This might not be a problem for Observables that are created rarely and emit just a few items but, if there will be cases when a thousand Observables are created, it means that there will be a thousand threads! It's something that is best to be avoided by using other types of Schedulers.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.145.175.253