Source code: edu/emory/mathcs/util/concurrent/ThreadFactoryUser.java
1 /*
2 File: ThreadFactoryUser.java
3
4 Originally written by Doug Lea and released into the public domain.
5 This may be used for any purposes whatsoever without acknowledgment.
6 Thanks for the assistance and support of Sun Microsystems Labs,
7 and everyone contributing, testing, and using this code.
8
9 History:
10 Date Who What
11 28aug1998 dl refactored from Executor classes
12 */
13
14 package edu.emory.mathcs.util.concurrent;
15
16 /**
17 *
18 * Base class for Executors and related classes that rely on thread factories.
19 * Generally intended to be used as a mixin-style abstract class, but
20 * can also be used stand-alone.
21 * <p>[<a href="http://gee.cs.oswego.edu/dl/classes/edu/oswego/cs/dl/util/concurrent/intro.html"> Introduction to this package. </a>]
22 **/
23
24 public class ThreadFactoryUser {
25
26 protected ThreadFactory threadFactory_ = new PlainThreadFactory();
27
28 /**
29 * Set the factory for creating new threads.
30 * By default, new threads are created without any special priority,
31 * threadgroup, or status parameters.
32 * You can use a different factory
33 * to change the kind of Thread class used or its construction
34 * parameters.
35 * @param factory the factory to use
36 * @return the previous factory
37 **/
38
39 public synchronized ThreadFactory setThreadFactory(ThreadFactory factory) {
40 ThreadFactory old = threadFactory_;
41 threadFactory_ = factory;
42 return old;
43 }
44
45 /**
46 * Get the factory for creating new threads.
47 **/
48 public synchronized ThreadFactory getThreadFactory() {
49 return threadFactory_;
50 }
51
52 }