1.调用线程的方法
public void monitorServerMothod(){
logger.info("定时任务开始");
try {
List<YcServerMonitorPO> list = new CopyOnWriteArrayList<YcServerMonitorPO>();
list=monitorService.getServerMonitor();
executor.execute(new ServerMonitorThread(list));//传参
} catch (Exception e) {
logger.error("监控异常"+e.getMessage());
e.printStackTrace();
}
}
2.线程中的构造方法
private List<YcServerMonitorPO> list = new CopyOnWriteArrayList <YcServerMonitorPO>();
private IMonitorService monitorService = null;
public ServerMonitorThread(List<YcServerMonitorPO> list){
this.list = list;
monitorService = (IMonitorService) SpringUtil.getBean("monitorService");
}
public void run() {
/**...*/
}