gaobiaoqing
gaobiaoqing

Reputation: 68

Rxjava why Schedulers.trampoline() named 'trampoline'?

in rxjava there are some Schedulers, just like io(),newThread()..., there have one Scheduler named 'trampoline' ,this Scheduler used for: Creates and returns a Scheduler that queues work on the current thread to be executed after the current work completes.

I can't understand why this scheduler named 'trampoline' but not 'queue' (or other name like 'queue').

Do you have a same puzzle ?

Upvotes: 4

Views: 1495

Answers (1)

paul
paul

Reputation: 13471

When you read this quote in the documentation

All jobs that subscribes on trampoline() will be queued and executed one by one

Then you understand why, have you try to use a trampoline when you was a child two friends at the same time?, impossible right?

This post explain quite well the differences between io and trampoline https://medium.com/@I_Love_Coding/rxjava-schedulers-trampoline-use-cases-283f6649cbf#.9hsjmyto2

Upvotes: 5

Related Questions