Android - 连续线程的 AsyncTask
Android - AsyncTask for continuous thread
在不使用 get
的情况下使用 AsyncTask
class 对象来创建持续 运行 线程是否安全? (等涉及 while
循环)
如果你想要运行一个长进程或需要后台任务运行,你需要一个Service而不是一个AsyncTask。
来自 javadoc :
AsyncTasks should ideally be used for short operations (a few seconds at the most.) If you need to keep threads running for long periods of time, it is highly recommended you use the various APIs provided by the java.util.concurrent package such as Executor, ThreadPoolExecutor and FutureTask.
所以,不:不推荐。
在不使用 get
的情况下使用 AsyncTask
class 对象来创建持续 运行 线程是否安全? (等涉及 while
循环)
如果你想要运行一个长进程或需要后台任务运行,你需要一个Service而不是一个AsyncTask。
来自 javadoc :
AsyncTasks should ideally be used for short operations (a few seconds at the most.) If you need to keep threads running for long periods of time, it is highly recommended you use the various APIs provided by the java.util.concurrent package such as Executor, ThreadPoolExecutor and FutureTask.
所以,不:不推荐。