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 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.