Sending Operations to Multiple Threads

1.Dependencies and prerequisites

2.You should also read

3.Try it out

  DOWNLOAD THE SAMPLE

  ThreadSample.zip

  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.

4.Lessons

4.1 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 theRunnable interface.
4.2 Creating a Manager for Multiple Threads
Learn how to create an object that manages a pool of Thread objects and a queue of Runnableobjects. This object is called a ThreadPoolExecutor.
4.3 Running Code on a Thread Pool Thread
Learn how to run a Runnable on a thread from the thread pool.
4.4 Communicating with the UI Thread
Learn how to communicate from a thread in the thread pool to the UI thread.

Android 线程池系列教程(1)目录的更多相关文章

  1. Android 线程池系列教程(5)与UI线程通信要用Handler

    Communicating with the UI Thread 上一课 下一课 1.This lesson teaches you to Define a Handler on the UI Thr ...

  2. Android 线程池系列教程(2)Thread,Runnable是基类及如何写Run方法

    Specifying the Code to Run on a Thread 上一课   下一课 1.This lesson teaches you to Define a Class that Im ...

  3. Android 线程池系列教程(4) 启动线程池中的线程和中止池中线程

    Running Code on a Thread Pool Thread 上一课   下一课 1.This lesson teaches you to Run a Runnable on a Thre ...

  4. Android 线程池系列教程(3) 创建线程池

    Creating a Manager for Multiple Threads 上一课  下一课 1.This lesson teaches you to Define the Thread Pool ...

  5. Android(java)学习笔记267:Android线程池形态

    1. 线程池简介  多线程技术主要解决处理器单元内多个线程执行的问题,它可以显著减少处理器单元的闲置时间,增加处理器单元的吞吐能力.     假设一个服务器完成一项任务所需时间为:T1 创建线程时间, ...

  6. android线程池ThreadPoolExecutor的理解

    android线程池ThreadPoolExecutor的理解 线程池 我自己理解看来.线程池顾名思义就是一个容器的意思,容纳的就是ThreadorRunable, 注意:每一个线程都是需要CPU分配 ...

  7. android 线程池的使用

    转自http://www.trinea.cn/android/java-android-thread-pool/ Java(Android)线程池 介绍new Thread的弊端及Java四种线程池的 ...

  8. 《java.util.concurrent 包源码阅读》13 线程池系列之ThreadPoolExecutor 第三部分

    这一部分来说说线程池如何进行状态控制,即线程池的开启和关闭. 先来说说线程池的开启,这部分来看ThreadPoolExecutor构造方法: public ThreadPoolExecutor(int ...

  9. Android(java)学习笔记211:Android线程池形态

    1. 线程池简介  多线程技术主要解决处理器单元内多个线程执行的问题,它可以显著减少处理器单元的闲置时间,增加处理器单元的吞吐能力.     假设一个服务器完成一项任务所需时间为:T1 创建线程时间, ...

随机推荐

  1. MySQL基础笔记(三) 复杂查询

    所谓复杂查询,指涉及多个表.具有嵌套等复杂结构的查询.这里简要介绍典型的几种复杂查询格式. 一.连接查询 连接是区别关系与非关系系统的最重要的标志.通过连接运算符可以实现多个表查询.连接查询主要包括内 ...

  2. MaterialImageView

    https://github.com/zhaozhentao/MaterialImageView

  3. 暴力破解zip文件

    #coding=utf-8 """ 用户输入-z参数指定要破解的zip文件,输入-d参数输入字典文件,即可暴力破解加密的zip文件 """ ...

  4. Java 文件路径的读取

    记得在操作系统中了解到文件读取有两种方式,当然这在各编程语言中也是通用的,所以java路径也分,相对和绝对路径. 绝对路径 绝对路径URI ,听着和URL非常相似.那我们就来看看吧. URI(Unif ...

  5. XMU 1611 刘备闯三国之卖草鞋 【贪心】

    1611: 刘备闯三国之卖草鞋 Time Limit: 1000 MS  Memory Limit: 64 MBSubmit: 90  Solved: 48[Submit][Status][Web B ...

  6. mysql13---索引使用注意

    .4唯一索引 ①当表的某列被指定为unique约束时,这列就是一个唯一索引 ) unique); 这时, name 列就是一个唯一索引. unique字段可以为NULL,并可以有多NULL(,null ...

  7. mysql数据库ip与字符串

    Mysql自带的IP转换语句 inet_aton:将ip地址转换成数字型 inet_ntoa:将数字型转换成ip地址 //使用inet_aton函数,将字符串IP转换为整型: mysql> se ...

  8. 关于页面上输入框中 空格 、0 、NULL 的处理 示例

    ep.setPositionNum(get("positionNum").toString()); ep.setClasstype(get("classtype" ...

  9. 【Codevs1346】HelloWorld编译器

    http://codevs.cn/problem/1346/ 可怜我战绩 // <1346.cpp> - 10/30/16 17:12:09 // This file is made by ...

  10. 我的第一篇博文,Python+scrapy框架安装。

    自己用Python脚本写爬虫有一段时日了,也抓了不少网页,有的网页信息两多,一个脚本用exe跑了两个多月,数据还在进行中.但是总觉得这样抓效率有点低,问题也是多多的,很早就知道了这个框架好用,今天终于 ...