首页 技术 正文
技术 2022年11月16日
0 收藏 744 点赞 4,790 浏览 1284 个字

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.
相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:9,488
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,903
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,737
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,489
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:8,128
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:5,290