首页 > 代码库 > 线程每5分钟刷新一次

线程每5分钟刷新一次



final ScheduledExecutorService scheduledExecutorService=Executors.newScheduledThreadPool(1);

scheduledExecutorService.scheduleAtFixedRate(new Runnable() {
@Override
public void run() {
Map<Integer, Province> allMapProvince = iRedisService.getAllProvince();
provincesHashMap.putAll(allMapProvince);
citiesHashMap.putAll(loadCityProvinceData(allMapProvince));
logger.info("scheduledExecutorService.scheduleAtFixedRate.run,data:{}",JSON.toJSONString(allMapProvince));
}
},0,5,TimeUnit.MINUTES);

线程每5分钟刷新一次