scheduleWithFixedDelay lambda 写法
scheduledExecutorService.scheduleWithFixedDelay(() -> refreshAccessToken(), REFRESH_CHECK_INTERVAL, REFRESH_CHECK_INTERVAL, TimeUnit.MILLISECONDS);
上面的写法相当于 以下:
scheduledExecutorService.scheduleWithFixedDelay(new Runnable() {
public void run() {
System.out.println("exectue start time =" + LocalTime.now().format(DateTimeFormatter.ofPattern("HH:mm:ss")));
System.out.println("scheule at fixed run...,threadName=" + Thread.currentThread().getName());
try {
//TODO
}catch (Exception e){
}
System.out.println("finish time=" + LocalTime.now().format(DateTimeFormatter.ofPattern("HH:mm:ss")));
}
},0,5,TimeUnit.SECONDS);