The Schedulers.fromExecutor enables us to build a scheduler over the Java ExecutorService. The scheduler does not own thread generation, but instead, it is controlled by the underlying ExecutorService. The scheduler should not be favored over other schedulers, as the life cycle of the ExecutorService must be managed by the developer. Consider the following code:
@Test public void testExecutorScheduler() throws Exception{ // Removed for Brevity ExecutorService executor = Executors.newSingleThreadExecutor(); fibonacciGenerator .filter(x -> { print("Executing Filter"); return x < 100; }).delayElements(Duration.ZERO,Schedulers.fromExecutor(executor)) .doOnNext(x -> print("Next value is "+ x)) .doFinally(x -> print("Closing ...