Schedulers.trampoline()

Schedulers.single() and Schedulers.trampoline() sound somewhat similar, both the schedulers are for sequential execution. While Schedulers.single() guarantees that all its task will run sequentially, it may run parallel to the thread it was called upon (if not, that thread is from Schedulers.single() as well); the Schedulers.trampoline() is different in that sector.

Unlike maintaining a thread to its disposal like Schedulers.single(), Schedulers.trampoline() queues up the task on the thread it was called on.

So, it'll be sequential with the thread it was called upon.

Let's look at some examples of Schedulers.single() and Schedulers.trampoline() to understand them better:

 fun main(args: Array<String>) { async(CommonPool) ...

Get Reactive Programming in Kotlin now with O’Reilly online learning.

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