-
Notifications
You must be signed in to change notification settings - Fork 780
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
2019-04-15:AsyncTask的优点和缺点? #28
Comments
优点:使用方便,然后没了 |
优点:AsyncTask操作简单,轻便,适用简单的异步操作。 |
优点:使用方便,既可以执行串行任务,也可以执行并行任务 |
有点:方便 |
AsyncTask的实现原理: 2.AsyncTask<Params,Progress,Result>,其中Params是doInBackground()方法的参数类型,Result是doInBackground()方法的返回值类型,Progress是onProgressUpdate()方法的参数类型。 3.当执行execute()方法的时候,其实就是调用SERIAL_EXECUTOR的execute()方法,就是把任务添加到队列的尾部,然后从头开始取出队列中的任务,调用THREAD_POOL_EXECUTOR的execute()方法依次执行,当队列中没有任务时就停止。 4.AsyncTask只能执行一次execute(params)方法,否则会报错。但是SERIAL_EXECUTOR和THREAD_POOL_EXECUTOR线程池都是静态的,所以可以形成队列。 Q:AsyncTask只能执行一次execute()方法,那么为什么用线程池队列管理 ? Q:AsyncTask的onPreExecute()、doInBackground()、onPostExecute()方法的调用流程? |
所有的asyctask 共享 两个线程池 一个用来排队 一个用来执行任务 |
优点: |
补充一个链接,我觉得说得不错的:http://www.voycn.com/article/asynctaskdequexianhezhuyishixiang |
Deprecated |
No description provided.
The text was updated successfully, but these errors were encountered: