2 * Written by Doug Lea with assistance from members of JCP JSR-166
3 * Expert Group and released to the public domain, as explained at
4 * http://creativecommons.org/licenses/publicdomain
7 package java.util.concurrent;
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.
15 * The simplest implementation of this interface is just:
17 * class SimpleThreadFactory implements ThreadFactory {
18 * public Thread newThread(Runnable r) {
19 * return new Thread(r);
24 * The {@link Executors#defaultThreadFactory} method provides a more
25 * useful simple implementation, that sets the created thread context
26 * to known values before returning it.
30 public interface ThreadFactory {
33 * Constructs a new <tt>Thread</tt>. Implementations may also initialize
34 * priority, name, daemon status, <tt>ThreadGroup</tt>, etc.
36 * @param r a runnable to be executed by new thread instance
37 * @return constructed thread
39 Thread newThread(Runnable r);