AsyncTask学习

参考资料:

Android实战技巧:深入解析AsyncTask

android线程池:http://blog.csdn.net/lyf_007217/article/details/8542238

http://www.111cn.net/sj/android/75318.htm

AsyncTask可能有的坑-Android

http://blog.csdn.net/shareus/article/details/50756833


execute

executeOnExecutor(AsyncTask.SERIAL_EXECUTOR)

是串行执行的

executorOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR)

是并行执行的。但是它每次容许的线程数量为5个,超过5个的线程需要排队等待


建议:

对于想要立即执行的异步任务,要么直接使用Thread ,要么单独创建线程池提供给AsyncTask 

使用自定义线程池的方法:

自定义corepoolsize = 7的Executor

Executors.newFixedThreadPool(7);

未设定限制的Executor

Executors.newCachedThreadPool();


Java Executor 框架 

http://blog.csdn.net/minword/article/details/20565867



猜你喜欢

转载自blog.csdn.net/haha_zhan/article/details/52117286