1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
package org.mule.module.launcher; |
12 | |
|
13 | |
import java.util.concurrent.ThreadFactory; |
14 | |
import java.util.concurrent.atomic.AtomicInteger; |
15 | |
|
16 | |
public class AppDeployerMonitorThreadFactory implements ThreadFactory |
17 | |
{ |
18 | |
|
19 | 0 | static final AtomicInteger poolNumber = new AtomicInteger(1); |
20 | |
final ThreadGroup group; |
21 | 0 | final AtomicInteger threadNumber = new AtomicInteger(1); |
22 | |
final String namePrefix; |
23 | |
|
24 | |
public AppDeployerMonitorThreadFactory() |
25 | 0 | { |
26 | 0 | SecurityManager s = System.getSecurityManager(); |
27 | 0 | group = (s != null) ? s.getThreadGroup() : |
28 | |
Thread.currentThread().getThreadGroup(); |
29 | 0 | namePrefix = String.format("Mule.app.deployer.monitor.%d.thread.", poolNumber.getAndIncrement()); |
30 | 0 | } |
31 | |
|
32 | |
public Thread newThread(Runnable r) |
33 | |
{ |
34 | 0 | Thread t = new Thread(group, r, |
35 | |
namePrefix + threadNumber.getAndIncrement(), |
36 | |
0); |
37 | |
|
38 | 0 | t.setDaemon(false); |
39 | 0 | t.setPriority(Thread.MIN_PRIORITY); |
40 | 0 | return t; |
41 | |
} |
42 | |
|
43 | |
|
44 | |
} |