RxJava - single thread asynchronous processing

£可爱£侵袭症+ 提交于 2020-01-05 04:06:47

问题


I have a question. Is possible run two tasks asynchronously in single threaded environment in RxJava? I know that Java should contain library for this functionality, but i think that RxJava does not contain it.


回答1:


Of course it contains single threaded asynchronous processing at it contains any thread count processing.

Example

Flowable.fromCallable(() ->{
            // do something
        })
                .subscribeOn(Schedulers.single());

Alternatives to Schedulers.single() is Schedulers.from(Executors.newFixedThreadPool(1)) where you can specify thread pool



来源:https://stackoverflow.com/questions/48267688/rxjava-single-thread-asynchronous-processing

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!