KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > hudson > util > DaemonThreadFactory


1 package hudson.util;
2
3 import java.util.concurrent.Executors JavaDoc;
4 import java.util.concurrent.ThreadFactory JavaDoc;
5
6 /**
7  * {@link ThreadFactory} that creates daemon threads.
8  *
9  * @author Kohsuke Kawaguchi
10  */

11 public class DaemonThreadFactory implements ThreadFactory JavaDoc {
12     private final ThreadFactory JavaDoc core;
13
14     public DaemonThreadFactory() {
15         this(Executors.defaultThreadFactory());
16     }
17
18     public DaemonThreadFactory(ThreadFactory JavaDoc core) {
19         this.core = core;
20     }
21
22     public Thread JavaDoc newThread(Runnable JavaDoc r) {
23         Thread JavaDoc t = core.newThread(r);
24         t.setDaemon(true);
25         return t;
26     }
27 }
28
Popular Tags