Android项目----AsyncTask异步操作

时间:2014-04-29 21:05:32   收藏:0   阅读:748

public abstract class

AsyncTask

extends Object

java.lang.Object
   ? android.os.AsyncTask<Params, Progress, Result>

Class Overview


 

AsyncTask enables proper and easy use of the UI thread. This class allows to perform background operations and publish results on the UI thread without having to manipulate threads and/or handlers.

AsyncTask is designed to be a helper class around Thread and Handler and does not constitute a generic threading framework. 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 pacakge such as ExecutorThreadPoolExecutor and FutureTask.

An asynchronous task is defined by a computation that runs on a background thread and whose result is published on the UI thread. An asynchronous task is defined by 3 generic types, called ParamsProgress and Result, and 4 steps, called onPreExecutedoInBackgroundonProgressUpdate and onPostExecute.

翻译:

AsyncTask能够适合,简单的用户界面线程。这个类允许执行后台操作在UI线程上返回操作结果,而无需操纵线程或处理程序

设计是围绕AsyncTask线程和处理器的一个辅助类,并不构成一个通用的线程框架。asynctasks用于短作业(最多几秒钟)如果你需要保持线程运行很长一段时间它是高度推荐你使用不同包裹java.util.concurrent执行API提供的,线程池futuretask

一个异步任务由计算运行在后台线程上,其结果发表在UI线程上定义。一个异步任务是由3的泛型类型定义称为参数过程和结果和4个步骤,被称为onpreexecute它的doInBackgroundonprogressupdateonpostexecute

 

一篇好博客推荐:http://www.cnblogs.com/devinzhang/archive/2012/02/13/2350070.html

Android项目----AsyncTask异步操作,布布扣,bubuko.com

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!