这是在服务(而非 IntentService)中使用 AsyncTask 的正常做法吗?还是以其他方式创建后台线程更好?
最佳答案
Is that a normal practice of using AsyncTask in Service
没有。 AsyncTask
的意义在于能够在后台工作完成后在主应用程序线程上做一些工作。服务很少(如果有的话)需要在主应用程序线程上工作。
Or is it better to create background thread in another way?
是的:new Thread()
将是 AsyncTask
的直接替代者。在其他情况下,某种形式的线程池可能有意义。
关于android - 在服务中使用 AsyncTask,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38468380/