AsyncTask 轻量级异步处理类,提供四个方法onPreExceute ,doInBackground,onProgressUpdate,onPostexceute,执行顺序onPreExceute->doInBackground->onProgressUpdate,onPostExceute,如果中间执行了onCancelled方法,则onPostExceute 是不会执行的。
exceute 方法一定要在主线程中调用,在Android3.0之前调用exceute为并行执行,在Android3.0之后,调用exceute方法为串行执行,为了解决高并发问题在android 3.0之后最好直接调用exceuteOoExceutor方法
HandlerThread 继承Handler,在子线程中更新UI时可以用此方法,不用自己单独写Looper的调用,handlerThread 创建时会自动创建Looper及handler。
IntentService 与service的区别:IntentService在onHandlerIntent中执行具体操作,并会自动调用stopSelf方法,intentservice可以启动多次每次都会调用onHandlerIntent方法,多次启动时intentService提按启动的顺序进行串行执行,执行结果与启动数相同时会自动调用stopSelf方法停止服务
service生命周期参见:https://blog.youkuaiyun.com/kuangren987/article/details/88063812