comparison src/EDU/oswego/cs/dl/util/concurrent/ThreadFactoryUser.java @ 0:3dc0c5604566

Initial checkin of blitz 2.0 fcs - no installer yet.
author Dan Creswell <dan.creswell@gmail.com>
date Sat, 21 Mar 2009 11:00:06 +0000
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:3dc0c5604566
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.oswego.cs.dl.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 DefaultThreadFactory();
27
28 protected static class DefaultThreadFactory implements ThreadFactory {
29 public Thread newThread(Runnable command) {
30 return new Thread(command);
31 }
32 }
33
34 /**
35 * Set the factory for creating new threads.
36 * By default, new threads are created without any special priority,
37 * threadgroup, or status parameters.
38 * You can use a different factory
39 * to change the kind of Thread class used or its construction
40 * parameters.
41 * @param factory the factory to use
42 * @return the previous factory
43 **/
44
45 public synchronized ThreadFactory setThreadFactory(ThreadFactory factory) {
46 ThreadFactory old = threadFactory_;
47 threadFactory_ = factory;
48 return old;
49 }
50
51 /**
52 * Get the factory for creating new threads.
53 **/
54 public synchronized ThreadFactory getThreadFactory() {
55 return threadFactory_;
56 }
57
58 }