Subversion Repositories XServices

Rev

Rev 102 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
102 brianR 1
/*
2
 *   Copyright 2013 Brian Rosenberger (Brutex Network)
3
 *
4
 *   Licensed under the Apache License, Version 2.0 (the "License");
5
 *   you may not use this file except in compliance with the License.
6
 *   You may obtain a copy of the License at
7
 *
8
 *       http://www.apache.org/licenses/LICENSE-2.0
9
 *
10
 *   Unless required by applicable law or agreed to in writing, software
11
 *   distributed under the License is distributed on an "AS IS" BASIS,
12
 *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
 *   See the License for the specific language governing permissions and
14
 *   limitations under the License.
15
 */
16
 
17
package net.brutex.xservices.util.cache;
18
 
19
import java.util.concurrent.Executors;
20
import java.util.concurrent.ThreadFactory;
21
/**
22
 * @author Brian Rosenberger, bru(at)brutex.de
23
 *
24
 */
25
 
26
 
27
public class DaemonThreadFactory
28
  implements ThreadFactory
29
{
30
  private final ThreadFactory factory;
31
 
32
  public DaemonThreadFactory()
33
  {
34
    this(Executors.defaultThreadFactory());
35
  }
36
 
37
  public DaemonThreadFactory(ThreadFactory factory)
38
  {
39
    if (factory == null)
40
      throw new NullPointerException("factory cannot be null");
41
    this.factory = factory;
42
  }
43
 
44
  public Thread newThread(Runnable r) {
45
    Thread t = this.factory.newThread(r);
46
    t.setDaemon(true);
47
    return t;
48
  }
49
}