asynctask

  • 网络异步任务
asynctaskasynctask
  1. For example , you can implement the previous example using AsyncTask this way

    例如,可以利用AsyncTask来实现上面的那个例子

  2. AsyncTask allows you to perform asynchronous work on your user interface .

    异步任务AsyncTask允许以异步的方式对用户界面进行操作。

  3. Naturally , the easiest way to avoid this situation is to use AsyncTask .

    当然,避免这种情况最好的办法是使用AsyncTask。

  4. AsyncTask just makes it easier to do both of these things .

    AsyncTask类只是把上面的两件事情变得简单了。

  5. Regardless of whether or not you use AsyncTask , always remember these two rules about the single thread model

    无论您是否使用AsyncTask,,都要记住单线程模型的两个规则

  6. With AsyncTask , you can really simplify multithreaded code .

    有了AsyncTask,您就完全可以简化多线程代码。

  7. Similarly , it returns an ArrayList because that is the third type parameter of the AsyncTask .

    类似地,它返回一个ArrayList,因为这是AsyncTask的第三个类型参数。

  8. It is also very important to remember that an AsyncTask instance has to be created on the UI thread and can be executed only once .

    同时,AsyncTask实例只能在UI线程中创建且只能执行一次。

  9. To use it , you must subclass AsyncTask and implement the doInBackground () callback method , which runs in a pool of background threads .

    要使用异步任务,必须继承AsyncTask类并实现doInBackground()回调方法,该对象将运行于一个后台线程池中。

  10. Perhaps the best solution , though , is to extend the AsyncTask class , which simplifies the execution of worker thread tasks that need to interact with the UI .

    当然,最好的解决方案也许就是继承使用异步任务类AsyncTask,此类简化了一些工作线程和UI交互的操作。