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. Hibernate复习之Hibernate基本介绍

    众所周知.眼下流行的面向对象的对象关系映射的Java持久层框架有MyBatis和Hibernate.他们都是对象关系映射ORM. 解决的主要问题就是对象-关系的映射.域模型和关系模型都分别建立在概念模 ...

  2. POJ3255 Roadblocks 【次短路】

    Roadblocks Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 7760   Accepted: 2848 Descri ...

  3. Redis系列之-—Redis-cli命令总结【转】

    Redis-cli命令最新总结 参考资料: http://redisdoc.com/ 或者 http://doc.redisfans.com http://redis.io/commands 一. 进 ...

  4. java的自动类型转换

    package BaseType; /*java的自动类型提升和窄化转换 * * 1. 当一个char,short,byte类型的变量被赋值给一个超出他自身能表示的最大范围的数,java会自动将该数转 ...

  5. phpqrcode生成带logo的二维码图片及带文字的二维码图片

    <?php require_once "./phpqrcode/phpqrcode.php"; /** * 这样就可以生成二维码了,实际上在png这个方法里还有几个参数需要使 ...

  6. C语言变长数组data[0]总结

    C语言变长数组data[0] 1.前言 今天在看代码中遇到一个结构中包含char data[0],第一次见到时感觉很奇怪,数组的长度怎么可以为零呢?于是上网搜索一下这样的用法的目的,发现在linux内 ...

  7. 在CentOS上把Nginx从1.2.4升级到1.6.0

    在CentOS上升级把Nginx从1.2.4升级到1.6.0 摘要:本文记录了在CentOS 6.3上,把Nginx从1.2.4升级到1.6.0的过程. 1. 概述 在我做的一个项目中,最近我对生产服 ...

  8. UML之实现图

    我们前面学过的用例图.类图.活动图.顺序图和协作图都描写叙述了逻辑和设计方面的信息.那么如今我们来学习和实现有关的两个图:构件图和部署图. 实现图用来描写叙述实现方面的信息,它从系统的层次来描写叙述下 ...

  9. 一个DIV相对于另一个DIV定位

    <div style="position:relative"><div style="position:absolute; top:0px; left: ...

  10. 如何快速定位JVM中消耗CPU最多的线程? Java 性能调优

    https://mp.weixin.qq.com/s/ZqlhPC06_KW6a9OSgEuIVw 上面的线程栈我们注意到 nid 的值其实就是线程 ID,它是十六进制的,我们将消耗 CPU 最高的线 ...