LogCollManager.java
1.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package com.sitech.ismp.coll.busi.util;
import java.util.HashMap;
import java.util.Map;
import org.apache.log4j.Logger;
import com.sitech.ismp.coll.busi.LogCollThread;
/**
* ClassName:LogCollManager
* Description: 对日志采集线程进行管理
*
* @author Linxc
* @version
* @since Ver 1.1
* @Date 2012 Feb 23, 2012 10:33:39 AM
*/
public class LogCollManager {
private static Logger logger = Logger.getLogger("BUSI_COLL");
private static Map<String,LogCollThread> threadPool = new HashMap<String, LogCollThread>();
public static void add(String id,LogCollThread thread){
threadPool.put(id, thread);
thread.start();
logger.info("Add new LogCollThread: " + id);
}
public static void remove(String id) {
LogCollThread thread = threadPool.get(id);
if (thread == null) {
return;
}
if (thread.isRunFlag()) {
thread.setRunFlag(false);
logger.info("Stop LogCollThread: " + id);
}
threadPool.remove(id);
logger.info("Remove LogCollThread: " + id);
}
public static boolean contains(String id) {
return threadPool.containsKey(id);
}
}