Sending Operations to Multiple Threads_翻译
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 theRunnableinterface. - Creating a Manager for Multiple Threads
- Learn how to create an object that manages a pool of
Threadobjects and a queue ofRunnableobjects. This object is called aThreadPoolExecutor. - Running Code on a Thread Pool Thread
- Learn how to run a
Runnableon 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_翻译的更多相关文章
- 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 ...
- Supporting Multiple Screens 翻译 支持各种屏幕(上)
Supporting Multiple Screens 支持各种各样的屏幕尺寸.屏幕密度 Android runs on a variety of devices that offer differe ...
- Android Training
Building Apps with Content Sharing Simple Data --> Intent && ActionProvider 介绍如何让应用程序共享简单 ...
- Android 线程池系列教程(1)目录
Sending Operations to Multiple Threads 1.Dependencies and prerequisites Android 3.0 (API Level 11) o ...
- PatentTips - Controlling TSC offsets for multiple cores and threads
BACKGROUND Many processors include a time stamp count (TSC) counter which is typically implemented a ...
- redis该如何分区-译文(原创)
写在最前,最近一直在研究redis的使用,包括redis应用场景.性能优化.可行性.这是看到redis官网中一个链接,主要是讲解redis数据分区的,既然是官方推荐的,那我就翻译一下,与大家共享. P ...
- Simple Network Management Protocol - SNMP Tutorial
30.9 Simple Network Management Protocol Network management protocols specify communication between t ...
- [转]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 ...
- HGOI20180817 (NOIP模拟Day1 task)
HGOI自测 初测:150=80+20+50 rank1~rank3(并列3个rank1,所以我是rank3 qwq) 今日分突然想简约 CF359A Table https://www.luogu. ...
随机推荐
- Qt打开外部程序和文件夹需要注意的细节(注意QProcess的空格问题,以及打开本地文件时,需要QUrl::fromLocalFile才可以)
下午写程序中遇到几个小细节,需要在这里记录一下. ? 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 QProcess *process = new QProcess(this ...
- C# ToolStrip在父窗体失去焦点时,点击里面的按钮无效
C#里面ToolStrip控件,在父窗体失去焦点的情况下,第一次点击ToolStrip上面的按钮,只是让父窗体获得焦点,并不会引发按钮的Click事件.要执行按钮操作必须再点击一次.相当于说,在父窗体 ...
- ef调用 access
<add name="AccessConnection" connectionString="Provider=Microsoft.ACE.OleDb.12.0;D ...
- uniDAC使用sqlite3作为 IOS APP 的数据库存在的问题
前面有写,可以利用uniConnection的ForceCreateDatabase参数,强制建立sqlite本地数据库, uniConnection1.SpecificOptions.Values[ ...
- 深入了解Windows句柄到底是什么(句柄是逻辑指针,或者是指向结构体的指针,图文并茂,非常清楚)good
总是有新入门的Windows程序员问我Windows的句柄到底是什么,我说你把它看做一种类似指针的标识就行了,但是显然这一答案不能让他们满意,然后我说去问问度娘吧,他们说不行网上的说法太多还难以理解. ...
- 使用VS2010开发Qt程序的4点经验(QT4到QT5的升级,更改sln文件,切换工程使用的Qt库,在VS的Solution Explorer视图中建立文件夹)
导读 相比于Qt Creator,我更喜欢用VS2010来进行开发.虽然启动时间相对较慢,但是VS下强大的快捷键和丰富的插件,以及使用多年的经验,都让我觉得在开发过程中得心应手.其中最重要的一点是,有 ...
- rest_framework
一.解析器组件(parser) 1.编程:数据结构和算法的结合 2.restful规范 定义:url唯一定位资源,http请求方式区分用户行为 (1)接口设计规范 (2)返回数据规范 (3)错误消息规 ...
- python算法与数据结构-双向链表(40)
一.双向链表的介绍 一种更复杂的链表是“双向链表”或“双面链表”.每个节点有两个链接:一个指向前一个节点,当此节点为第一个节点时,指向空值:而另一个指向下一个节点,当此节点为最后一个节点时,指向空值. ...
- mybatis以及预编译如何防止SQL注入
SQL注入是一种代码注入技术,用于攻击数据驱动的应用,恶意的SQL语句被插入到执行的实体字段中(例如,为了转储数据库内容给攻击者).[摘自] SQL injection - Wikipedia SQL ...
- Map集合的4种遍历方式
import java.util.HashMap;import java.util.Iterator;import java.util.Map; public class TestMap { p ...