ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/jsr166/jsr166/src/main/java/util/concurrent/ThreadFactory.java
Revision: 1.14
Committed: Thu Jun 9 07:48:43 2011 UTC (12 years, 11 months ago) by jsr166
Branch: MAIN
Changes since 1.13: +2 -3 lines
Log Message:
consistent style for code snippets

File Contents

# User Rev Content
1 tim 1.1 /*
2 dl 1.2 * Written by Doug Lea with assistance from members of JCP JSR-166
3 dl 1.6 * Expert Group and released to the public domain, as explained at
4 jsr166 1.13 * http://creativecommons.org/publicdomain/zero/1.0/
5 tim 1.1 */
6    
7     package java.util.concurrent;
8    
9     /**
10     * An object that creates new threads on demand. Using thread factories
11     * removes hardwiring of calls to {@link Thread#Thread(Runnable) new Thread},
12     * enabling applications to use special thread subclasses, priorities, etc.
13     *
14 jsr166 1.7 * <p>
15 dl 1.5 * The simplest implementation of this interface is just:
16 jsr166 1.14 * <pre> {@code
17 dl 1.5 * class SimpleThreadFactory implements ThreadFactory {
18     * public Thread newThread(Runnable r) {
19     * return new Thread(r);
20     * }
21 jsr166 1.14 * }}</pre>
22 dl 1.5 *
23     * The {@link Executors#defaultThreadFactory} method provides a more
24     * useful simple implementation, that sets the created thread context
25 jsr166 1.7 * to known values before returning it.
26 tim 1.1 * @since 1.5
27 dl 1.3 * @author Doug Lea
28 tim 1.1 */
29 jsr166 1.7 public interface ThreadFactory {
30 tim 1.1
31     /**
32 jsr166 1.11 * Constructs a new {@code Thread}. Implementations may also initialize
33     * priority, name, daemon status, {@code ThreadGroup}, etc.
34 tim 1.1 *
35     * @param r a runnable to be executed by new thread instance
36 jsr166 1.12 * @return constructed thread, or {@code null} if the request to
37 jsr166 1.11 * create a thread is rejected
38 tim 1.1 */
39     Thread newThread(Runnable r);
40     }