-1
我是新的弹簧与ExecutorService
。请你确认下面的代码吗?我在@PostConstruct
方法initailized ExecutorSerive
并在@PreDestroy
method.Is destoryed它有一个需要调用shutdownNow()
。如果是的话,它会在哪里?弹簧与执行器服务
private static final int FIXED_THREAD_POOL_SIZE =3;
private static final Log LOGGER = LogFactory.getLog(HotelProgramInfoHistoryService.class);
private ExecutorService executorService;
@PostConstruct
public void initialize() throws Exception {
if(executorService == null) {
this.executorService = Executors.newFixedThreadPool(FIXED_THREAD_POOL_SIZE);
}
}
public void sendRequest(DomainSecurity security, HotelProgramInfo hotelProgramInfo) {
try {
ProgramInfoHistoryUpdateTask programInfoHistoryUpdateTask = new ProgramInfoHistoryUpdateTask(hotelProgramInfo);
this.executorService.submit(programInfoHistoryUpdateTask);
} catch (Exception exception) {
LOGGER.error("Exception occurred while submitting update task ", exception);
}
}
@PreDestroy
public void cleanUp() throws Exception {
if(executorService != null)
{
executorService.shutdown();
}
}
}