WorkManager系列(十一)Threading in WorkManager_OverView

In previous sections, we mentioned that WorkManager performs background work asynchronously on your behalf. The basic implementation addresses the demands of most apps. For more advanced use cases, such as correctly handling work being stopped, you should learn about threading and concurrency in WorkManager.

There are four different types of work primitives provided by WorkManager:

  • Worker is the simplest implementation, and the one you have seen in previous sections. WorkManager automatically runs it on a background thread (that you can override). Read more about threading in Workers in Threading in Worker.
  • CoroutineWorker is the recommended implementation for Kotlin users. CoroutineWorkers expose a suspending function for background work. By default, they run a default Dispatcher, which you can customize. Read more about threading in CoroutineWorkers in Threading in CoroutineWorker.
  • RxWorker is the recommended implementation for RxJava2 users. RxWorkers should be used if a lot of your existing asynchronous code is modelled in RxJava. As with all RxJava2 concepts, you are free to choose the threading strategy of your choice. Read more about threading in RxWorkers in Threading in RxWorker.Read more about threading in RxWorkers in Threading in RxWorker.
  • ListenableWorker is the base class for WorkerCoroutineWorker, and RxWorker. It is intended for Java developers who have to interact with callback-based asynchronous APIs such as FusedLocationProviderClientand are not using RxJava2. Read more about threading in ListenableWorkers in Threading in ListenableWorker.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值