자바 의 정시 폴 링

1690 단어 자바

ScheduledExecutorService service = Executors.newScheduledThreadPool(10);
service.scheduleAtFixedRate(() -> {

LocalDateTime start = LocalDateTime.now().withNano(0).minusSeconds(1);
LocalDateTime end = LocalDateTime.now().withNano(0);
List strings=null;
for (int index = 0; index < GET_RETRY_TIMES; index++) {

try {



} catch (Exception e) {
System.out.println("shibai%d" + start + end);
logger.error(String.format(" :[%s], :[%s]", start.toString(), end.toString()));
}
}
for (int index = 0; index < SET_RETRY_TIMES; index++) {
try {

queueService.orderMsetMessage(strings);
break;

} catch (Exception e) {
System.out.println(start.toString()+end.toString());
logger.error(String.format(" :[%s], :[%s]", start.toString(), end.toString()));

}
}

}, 0, 1, TimeUnit.SECONDS);

java ,Timer   , , schedule scheduleAtFixedRate ,

(1)schedule :“fixed-delay”; delay ,        
(2)scheduleAtFixedRate :“fixed-rate”; delay ,     , ”catch up” ,TimerTask

다음으로 전송:https://www.cnblogs.com/jie123/p/5450149.html

좋은 웹페이지 즐겨찾기