What is the difference between Schedulers.io() and Schedulers.computation()

后端 未结 2 764
清酒与你
清酒与你 2021-02-07 02:20

I use Observables in couchbase.

What is the difference between Schedulers.io() and Schedulers.computation()?

2条回答
  •  青春惊慌失措
    2021-02-07 02:22

    From the documentation of rx:

    Schedulers.computation( ) - meant for computational work such as event-loops and callback processing; do not use this scheduler for I/O (use Schedulers.io( ) instead); the number of threads, by default, is equal to the number of processors


    Schedulers.io( ) - meant for I/O-bound work such as asynchronous performance of blocking I/O, this scheduler is backed by a thread-pool that will grow as needed; for ordinary computational work, switch to Schedulers.computation( ); Schedulers.io( ) by default is a CachedThreadScheduler, which is something like a new thread scheduler with thread caching

提交回复
热议问题