如何同时运行多个doAsync?

时间:2019-02-17 18:23:53

标签: android kotlin anko

我正在使用Anko库执行一些后台任务,我在前台服务中运行了doAsync。同时,我正在通过从数据库中获取数据来更新recyclerview。但是问题在于,当前台服务doAsync运行时,不会调用recyclerview更新doAsync。

我不知道为什么它不打电话,我不能同时运行多个doAsync吗?

1 个答案:

答案 0 :(得分:1)

Asynchronous vs synchronous execution, what does it really mean?

doasync runs multiple tasks in a 'first in first executed'(what you explained) sequence in one background thread(not multiple threads); so like asynctask by creating multiple instances of it you're just creating multiple tasks;

you need to start a new thread for each of your tasks if you want all the tasks to run asynchronously relative to each other;