小编fir*_*ly3的帖子

Android中处理程序和AsyncTask之间的一个区别

为什么AsyncTask只能完成一项工作?例如,

task = new SubAsyncTask(...); // assume the parameter is correct.
task.execute(...) //
task.execute(...)// calling once again, it throws exeception.
Run Code Online (Sandbox Code Playgroud)

但是,a Handler可以不断执行多项任务:

hd = new Handler(...); // assume the parameter is correct
hd.sendMessage(...); //
hd.sendMessage(...);// no exeception is thrown.
Run Code Online (Sandbox Code Playgroud)

AasyncTask只是一次性工作的对象吗?如果我不想为类似的任务创建多个对象,我应该选择Handler吗?

android

4
推荐指数
1
解决办法
4110
查看次数

标签 统计

android ×1