The trampoline() operator

The trampoline() operator returns a default, shared an instance of the Scheduler which has a Scheduler.Worker instance queues the work and executes it in FIFO style. However, we cannot use it to reliably return the execution of the tasks to the current thread. The default implementation of the Scheduler executes the task on the current thread without any queuing, which adds time overload. The trampoline is a pattern in the functional programming. It facilitates the implementation of recursion without giving infinite calls for growing the stack. The idea behind it is to remove the current execution from the stack to eliminate the on-going stack. It manages to queue up the tasks one by one. The Scheduler starts with ...

Get Reactive Programming With Java 9 now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.