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.

Sending Operations to Multiple Threads_翻译的更多相关文章

  1. Creating a Manager for Multiple Threads_翻译

    The previous lesson showed how to define a task that executes on a separate thread. If you only want ...

  2. Supporting Multiple Screens 翻译 支持各种屏幕(上)

    Supporting Multiple Screens 支持各种各样的屏幕尺寸.屏幕密度 Android runs on a variety of devices that offer differe ...

  3. Android Training

    Building Apps with Content Sharing Simple Data --> Intent && ActionProvider 介绍如何让应用程序共享简单 ...

  4. Android 线程池系列教程(1)目录

    Sending Operations to Multiple Threads 1.Dependencies and prerequisites Android 3.0 (API Level 11) o ...

  5. PatentTips - Controlling TSC offsets for multiple cores and threads

    BACKGROUND Many processors include a time stamp count (TSC) counter which is typically implemented a ...

  6. redis该如何分区-译文(原创)

    写在最前,最近一直在研究redis的使用,包括redis应用场景.性能优化.可行性.这是看到redis官网中一个链接,主要是讲解redis数据分区的,既然是官方推荐的,那我就翻译一下,与大家共享. P ...

  7. Simple Network Management Protocol - SNMP Tutorial

    30.9 Simple Network Management Protocol Network management protocols specify communication between t ...

  8. [转]50 Shades of Go: Traps, Gotchas, and Common Mistakes for New Golang Devs

    http://devs.cloudimmunity.com/gotchas-and-common-mistakes-in-go-golang/ 50 Shades of Go: Traps, Gotc ...

  9. HGOI20180817 (NOIP模拟Day1 task)

    HGOI自测 初测:150=80+20+50 rank1~rank3(并列3个rank1,所以我是rank3 qwq) 今日分突然想简约 CF359A Table https://www.luogu. ...

随机推荐

  1. vs2015未能正确加载“ProviderPackage”包。

    原文:vs2015未能正确加载“ProviderPackage”包. 出现以下错误的解决方案 --------------------------- Microsoft Visual Studio - ...

  2. GlusterFS集群文件系统研究(负载均衡的最常用办法) good

    http://blog.csdn.net/liuaigui/article/details/6284551 http://blog.csdn.net/liuaigui/article/details/ ...

  3. C# 泛型 无法将类型xx隐式转换为“T”

    原文:C# 泛型 无法将类型xx隐式转换为“T” 直接奖泛型转为T是不能转换的 要先转Object 例: public static T GetValue<T>(string inValu ...

  4. Java中的逆变与协变 专题

    结论先行: PECS总结: 要从泛型类取数据时,用extends: 协变 要往泛型类写数据时,用super: 逆变 既要取又要写,就不用通配符(即extends与super都不用) 不变 List&l ...

  5. Android零基础入门第68节:完善RecyclerView,添加首尾视图

    在之前学习ListView的时候,有学习过如何给ListView添加列表头和列表尾.但是通过近几期的学习,发现RecyclerView是一个比ListView更加强大和灵活的组件,今天一起来学习如何给 ...

  6. 使用AnimateWindow来实现窗口淡入淡出(主要有四种动画,滚动,滑动,折叠或展开,和淡入淡出)

    如果是在VC6下进行编译,应引入下面的预编译宏,注意放在windows.h的前面#undef  WINVER   #define  WINVER   0x500为什么要引入上面的宏呢?看看winuse ...

  7. ZooKeeper+Dubbo+SpringBoot 微服务Demo搭建

    1. 首先创建springBoot项目,springBoot是一堆组件的集合,在pom文件中对需要的组件进行配置.生成如下目录结构 创建test项目,同步在test创建dubbo-api,dubbo- ...

  8. 多线程基础理论--C#

    1.主线程 进程创建时,默认创建一个线程,这个线程就是主线程.主线程是产生其他子线程的线程,同时,主线程必须是最后一个结束执行的线程,它完成各种关闭其他子线程的操作.尽管主线程是程序开始时自动创建的, ...

  9. HTML连载14-文字属性补充&简写

    一.字体属性(补充) 1.如果设置的字体不存在,那么系统会使用默认的字体来显示宋体. font-family:"瞎写的一个字体"; 2.如果设置的字体不存在,而我们又不想用默认的字 ...

  10. Adam和学习率衰减(learning learning decay)

    目录 梯度下降法更新参数 Adam 更新参数 Adam + 学习率衰减 Adam 衰减的学习率 References 本文先介绍一般的梯度下降法是如何更新参数的,然后介绍 Adam 如何更新参数,以及 ...