The speed and efficiency of a long-running, data-intensive operation often improves when you split it into smaller operations running on multiple threads. On a device that has a CPU with multiple processors (cores), the system can run the threads in parallel, rather than making each sub-operation wait for a chance to run. For example, decoding multiple image files in order to display them on a thumbnail screen runs substantially faster when you do each decode on a separate thread.

当你将一个需要长时间运行的,聚焦于数据的操作,分割成一些小的操作,并且在多线程中运行的话,那么这个长时间运行的操作的速度和效率将会提升不少。对于一个有多核的设备,系统可以并发的运行多个线程,而不是让每个子操作等到被执行。比如,当你要解码多张图片,以在屏幕上显示的话,你如果将每一个图片的解码操作放在每一个独立的线程的话,那么速度将会很快。

This class shows you how to set up and use multiple threads in an Android app, using a thread pool object. You'll also learn how to define code to run on a thread and how to communicate between one of these threads and the UI thread.

本课程将会向你展示,如何通过一个线程池对象,来创立和使用多线程。你同样也会学到如何使得代码在线程中宇星,以及这些线程如何与主线程通信。

Lessons


Specifying the Code to Run on a Thread
Learn how to write code to run on a separate Thread, by defining a class that implements the Runnable interface.
Creating a Manager for Multiple Threads
Learn how to create an object that manages a pool of Thread objects and a queue of Runnable objects. This object is called a ThreadPoolExecutor.
Running Code on a Thread Pool Thread
Learn how to run a Runnable on a thread from the thread pool.
Communicating with the UI Thread
Learn how to communicate from a thread in the thread pool to the UI thread.

最新文章

  1. 在共享DLL中使用MFC
  2. delphi action学习
  3. codeforces 486B.OR in Matrix 解题报告
  4. 判断返回数据是否为 null
  5. IntelliJ IDEA中运行Tomcat报内存溢出(java.lang.OutOfMemoryError: PermGen space)
  6. Urxvt - awesome
  7. 通过位异或来交换a,b的值和通过中间变量交换a,b的值
  8. innobackupex: fatal error: no ‘innodb_buffer_pool_filename’解决方法
  9. Android开发技巧——自定义单选或多选的ListView
  10. 你真的知道.NET Framework中的阻塞队列BlockingCollection的妙用吗?
  11. git 本地同步分支数,删除远程已经删除掉的多余分支
  12. C#中的虚函数及继承关系
  13. lumion室内渲染二6.3
  14. 一、springBoot简介与环境搭建
  15. Module 10:I/O流(java如何实现与外界数据的交流)
  16. CF 166E Tetrahedron
  17. TextBox控件设置ReadOnly=true后台取不到值三种解决方法(转)
  18. Django 组件-cookie 与 session
  19. 关于junit包导入不了但是maven本地库中却存在的问题
  20. string 类(二)

热门文章

  1. Win8Metro(C#)数字图像处理--2.19图像水平镜像
  2. 使用Microsoft Power BI进行基本的数据分析
  3. 使用 Visual Studio 开发并调试 Mail Add-in (mail app for Outlook)
  4. 一些Windows API导致的Crash以及使用问题总结(API的AV失败,可以用try catch捕捉后处理)
  5. 检索 COM 类工厂中 CLSID 为 {{10020200-E260-11CF-AE68-00AA004A34D5}} 的组件时失败解决办法
  6. php PAC 安装
  7. SYN5301型 毫秒表时间检定仪
  8. java基础(1)-几种获取类的扩展方式
  9. Python基础,day1
  10. F4帮助