1page.title=Sending Operations to Multiple Threads
2page.tags=threadpool,runnable
3
4trainingnavtop=true
5startpage=true
6
7
8@jd:body
9
10<div id="tb-wrapper">
11<div id="tb">
12
13<!-- Required platform, tools, add-ons, devices, knowledge, etc. -->
14<h2>Dependencies and prerequisites</h2>
15<ul>
16    <li>Android 3.0 (API Level 11) or higher</li>
17    <li>
18        <a href="{@docRoot}training/load-data-background/index.html">
19        Loading Data in the Background</a> training class
20    </li>
21    <li>
22        <a href="{@docRoot}training/run-background-service/index.html">
23        Running in a Background Service</a> training class
24    </li>
25</ul>
26
27<!-- related docs (NOT javadocs) -->
28<h2>You should also read</h2>
29<ul>
30  <li><a href="{@docRoot}guide/components/processes-and-threads.html">Processes and Threads</a></li>
31</ul>
32
33<h2>Try it out</h2>
34<div class="download-box">
35    <a href="{@docRoot}shareables/training/ThreadSample.zip" class="button">Download the sample</a>
36    <p class="filename">ThreadSample.zip</p>
37</div>
38
39</div>
40</div>
41<p>
42    The speed and efficiency of a long-running, data-intensive operation often improves when you
43    split it into smaller operations running on multiple threads. On a device that has a CPU with
44    multiple processors (cores), the system can run the threads in parallel, rather than making each
45    sub-operation wait for a chance to run. For example, decoding multiple image files in order to
46    display them on a thumbnail screen runs substantially faster when you do each decode on a
47    separate thread.
48</p>
49<p>
50    This class shows you how to set up and use multiple threads in an Android app, using a
51    thread pool object. You'll also learn how to define code to run on a thread and how to
52    communicate between one of these threads and the UI thread.
53</p>
54<h2>Lessons</h2>
55<dl>
56    <dt>
57        <b><a href="define-runnable.html">Specifying the Code to Run on a Thread</a></b>
58    </dt>
59    <dd>
60        Learn how to write code to run on a separate {@link java.lang.Thread}, by
61        defining a class that implements the {@link java.lang.Runnable} interface.
62    </dd>
63    <dt>
64        <b><a href="create-threadpool.html">Creating a Manager for Multiple Threads</a></b>
65    </dt>
66    <dd>
67        Learn how to create an object that manages a pool of {@link java.lang.Thread} objects and
68        a queue of {@link java.lang.Runnable} objects. This object is called a
69        {@link java.util.concurrent.ThreadPoolExecutor}.
70    </dd>
71    <dt>
72        <b><a href="run-code.html">Running Code on a Thread Pool Thread</a></b>
73    </dt>
74    <dd>
75        Learn how to run a {@link java.lang.Runnable} on a thread from the thread pool.
76    </dd>
77    <dt>
78        <b><a href="communicate-ui.html">Communicating with the UI Thread</a></b>
79    </dt>
80    <dd>
81        Learn how to communicate from a thread in the thread pool to the UI thread.
82    </dd>
83</dl>
84
85