ExecutorService executorService = Executors.newSingleThreadExecutor();
executorService.execute(() -> {
try {
ObjectUtils.ifPresent(planList, list -> {
for (RFCPlanEntity entity : list) {
String status = entity.getStatus();
List<RFCUserEntity> implementerList = entity.getImplementer();
ObjectUtils.ifTrue("Implement".equals(status), implementerList, implementer -> {
rfcScoreService.queryAspAndSave(implementer);
});
}
});
} catch (ApplicationException e) {
e.printStackTrace();
}
});
@Configuration
public class SchedulingConfiguration implements SchedulingConfigurer {
public static int count = 0;
@Override
public void configureTasks(ScheduledTaskRegistrar taskRegistrar) {
//默认是一个线程
taskRegistrar.setScheduler(Executors.newScheduledThreadPool(10));
// taskRegistrar.setScheduler(new ScheduledThreadPoolExecutor(Runtime.getRuntime().availableProcessors(),
// new ThreadFactory() {
// @Override
// public Thread newThread(Runnable r) {
// return new Thread(r, "my-schedule-" + ++count);
// }
// }));
}
}