-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();
}
}
}