Executor Scheduler

One of the last Schedulers that we will cover is the Executor Scheduler. It was created to consume a custom pool created with an Executors class from the java.util.concurrent package. An example of how that can be done looks like this:

final ExecutorService executor = Executors.newFixedThreadPool(10);
final Scheduler pooledScheduler = Schedulers.from(executor);

Then, it's just a matter of passing and using it in .subscribeOn():

.subscribeOn(pooledScheduler)

This Scheduler can be used to create bounded worker pools that can replace IO Scheduler in cases where the chance of creating lots of Observables is quite likely.

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

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