本文介绍了RxJava-单线程异步处理的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个问题.是否可以在RxJava的单线程环境中异步运行两个任务?我知道Java应该包含此功能的库,但是我认为RxJava不包含它.
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.
推荐答案
当然,它包含单线程异步处理,并且包含任何线程计数处理.
Of course it contains single threaded asynchronous processing at it contains any thread count processing.
示例
Flowable.fromCallable(() ->{
// do something
})
.subscribeOn(Schedulers.single());
Schedulers.single()的替代方法是 Schedulers.from(Executors.newFixedThreadPool(1))
,您可以在其中指定线程池
Alternatives to Schedulers.single()
is Schedulers.from(Executors.newFixedThreadPool(1))
where you can specify thread pool
这篇关于RxJava-单线程异步处理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!