The elastic scheduler

The Schedulers.elastic scheduler executes work on a multiple-worker thread pool. Each of the executed workers can execute long-lived tasks that ask for a blocking operation. Each worker is returned to the pool when the task finishes. There is also an idle time associated with the worker, after which the worked is disposed. The scheduler tries to consume an existing idle worker, but if there aren't any, the scheduler dynamically generates one and schedules the task on it. The following code shows this:

@Test    public void testElasticSchedular() throws Exception{       // Removed for Brevity        fibonacciGenerator                .filter(x -> {                    print("Executing Filter");                    return x < 100;                }).delayElements(Duration.ZERO,Schedulers.elastic()) .window(10) ...

Get Hands-On Reactive Programming with Reactor now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.