Lines Matching refs:thread
35 separate thread. If you only want to run the task once, this may be all you need. If you want
40 {@link java.util.concurrent.ThreadPoolExecutor}, which runs a task from a queue when a thread
44 A thread pool can run multiple parallel instances of a task, so you should ensure that your
45 code is thread-safe. Enclose variables that can be accessed by more than one thread in a
46 <code>synchronized</code> block. This approach will prevent one thread from reading the variable
60 Use static variables for thread pools
63 You may only want a single instance of a thread pool for your app, in order to have a
65 {@link java.lang.Runnable} types, you may want to have a thread pool for each one, but each
89 * Constructs the work queues and thread pools used to download
99 Start your tasks by calling methods in the thread pool class.
102 Define a method in the thread pool class that adds a task to a thread pool's queue. For
112 // Adds a download task to the thread pool for execution
122 UI thread.
127 the UI thread. This approach is described in more detail in the lesson
132 // Defines a Handler object that's attached to the UI thread
150 Once you have the overall class structure, you can start defining the thread pool. To
160 The number of threads you can have in a thread pool depends primarily on the number of cores
182 The duration that a thread will remain idle before it shuts down. The duration is
191 {@link java.lang.Runnable} objects. To start code on a thread, a thread pool manager takes a
193 thread. You provide this queue object when you create the thread pool, using any queue class
217 To create a pool of threads, instantiate a thread pool manager by calling
221 all of the thread objects when it is instantiated. For example:
226 // Sets the amount of time an idle thread waits before terminating
230 // Creates a thread pool manager