blob: 4944605837ec9761d6d0490b548b05ce55b147ce (
plain)
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
|
package com.nms.server.thread.change;
import java.util.concurrent.Future;
import org.apache.log4j.Logger;
import com.nms.server.common.Common;
import com.nms.server.common.Constants;
/**
* 周期性检查数据库,将检索变更通讯并下发
* @date Mar 31, 2012 10:03:04 AM
* @author ZhangGang
*
*/
public class ChangeManagerThread implements Runnable{
Logger logger = Logger.getLogger(ChangeManagerThread.class);
@Override
public void run() {
//将线程运行程序,尽可能的catch捕获异常
try {
// Thread.currentThread().setName("变更操作管理线程");
Thread.currentThread().setName("Changing The Operation Management Thread");
Future<?> future = Common.getFutureMap().get(Constants.CHANGE_OPERATIONS);
if(future != null && !future.isCancelled() && !future.isDone()){ //运行中
logger.info("变更操作线程 运行中 不再启动新线程");
}else{
//为空或空闲中
logger.info("变更操作线程 空闲中 启动新线程");
// future = Common.service.submit(new ChangeThread("变更操作线程"));
future = Common.service.submit(new ChangeThread("Changing The Operating Thread"));
//注册
Common.getFutureMap().put(Constants.CHANGE_OPERATIONS, future);
}
} catch (Exception e) {
logger.error("",e);
}
}
}
|