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. 图像滤镜艺术--编码基础(Photoshop基础变换的代码实现)

    原文:图像滤镜艺术--编码基础(Photoshop基础变换的代码实现) 自从上一篇博客写完之后,到现在已经有段时间了,这段时间不是不想接着写,只是想做的更好了在写出来给大家看呵呵. 今天,我将给大家介 ...

  2. WPF ListboxItem 双击事件 Command绑定

    <ListBox x:Name="Lb" HorizontalAlignment="Left" Height="600" Vertic ...

  3. delphi 程序强制结束自身(两种方法都暴力)

    procedure KillSelf;begin  Sleep(1000);  if not TerminateProcess(GetCurrentProcessId, 0) then  WinExe ...

  4. UWP StorageFile StorageFolder StorageFileHelper

    //获取表示指定文件系统路径中的文件夹的 StorageFolder. StorageFolder folder1 = await StorageFolder.GetFolderFromPathAsy ...

  5. 高启全:长江存储自主3D NAND,DRAM研发欢迎美光一起加入(千秋大业,慢慢做)

    台湾DRAM教父高启全转战大陆紫光集团操盘存储器大计划超过1年,日前晋升长江存储的执行董事.代行董事长,接受DIGITIMES独家专访公开未来规划:他指出,已齐聚500名研发人员在武汉投入3D NAN ...

  6. Window文件目录遍历 和 WIN32_FIND_DATA 结构(非常详细的中文注释)

    第一部分     *百度百科提供的内容总结:WIN32_FIND_DAT 第二部分   *程序实例 第三部分   *一篇使用FindFirstFile和FindNextFile函数的博文   第一部分 ...

  7. [机器学习]SVM原理

    SVM是机器学习中神一般的存在,虽然自深度学习以来有被拉下神坛的趋势,但不得不说SVM在这个领域有着举足轻重的地位.本文从Hard SVM 到 Dual Hard SVM再引进Kernel Trick ...

  8. 为什么有如此多的C++测试框架 - from Google Testing Blog

    Why Are There So Many C++ Testing Frameworks? by Zhanyong Wan (Software Engineer) 最近貌似有很多人正在开发他们自己的C ...

  9. Windows Phone8.1系统新特性

    Windows Phone 8.1 beta SDK已经为大家透露了不少WP8.1系统的新特性,不过这些新特性还不能保证在最终的消费者版本中都有所体现,毕竟它还仅是SDK版本.日前,国外媒体WPCen ...

  10. 请你讲一讲JavaScript有哪些数据类型, 数据类型判断有哪些方法?

    js的8种数据类型 JavaScript中有8种数据类型, 包括基本数据类型(number, string, boolean, null, undefined, symbol, bigint)和引用数 ...