Zach
Zach

Reputation: 4069

RxJava2: How to get a dedicated background thread for work

Is it possible to schedule work on a dedicated background thread? I need to ensure the work is done in serial, but also it must be done on the background.

Basically - is there a combination of the trampoline and io schedulers out there?

Upvotes: 3

Views: 440

Answers (1)

Sergej Isbrecht
Sergej Isbrecht

Reputation: 4002

Just use a ThreadPool with only one Thread.

RxJava2 provides such a standard Scheduler:

Schedulers.single()

Or use the Factory method:

Schedulers.from(Executors.newSingleThreadExecutor())

Upvotes: 3

Related Questions