June 2017
Intermediate to advanced
400 pages
8h 44m
English
The Schedulers.newThread() factory will return a Scheduler that does not pool threads at all. It will create a new thread for each Observer and then destroy the thread when it is done. This is different than Schedulers.io() because it does not attempt to persist and cache threads for reuse:
Observable.just("Alpha", "Beta", "Gamma", "Delta", "Epsilon") .subscribeOn(Schedulers.newThread());
This may be helpful in cases where you want to create, use, and then destroy a thread immediately so it does not take up memory. But for complex applications generally, you will want to use Schedulers.io() so there is some attempt to reuse threads if possible. You also have to be careful as Schedulers.newThread() can run amok in complex applications ...
Read now
Unlock full access