public List<Long> syncHandleList(List<UgcDpSync> ugcDpSyncList){ if (CollectionUtils.isEmpty(ugcDpSyncList)){ return Collections.emptyList(); } CompletionService<List<Long>> cs = new ExecutorCompletionService<>(executor); List<Long> list = new ArrayList<>(); int loop = 0; try { cs.submit(() -> { List<Long> tmpList = new ArrayList<>(); for (UgcDpSync ugcDpSync : ugcDpSyncList) { if (ugcDpSync.getCommentId() != null){ System.out.println(ugcDpSync); tmpList.add(ugcDpSync.getCommentId()); } } return tmpList; }); loop++; if (loop % 1 == 0) { for (int i = 0; i < 1; i++) { try { List<Long> result = cs.take().get(); if (CollectionUtils.isNotEmpty(result)) { list.addAll(result); } } catch (Exception e) { } } } } catch (Exception e) { } try { Thread.sleep(500); } catch (Exception e1) { } return list; }