We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
@Override public List<Point> recordHandlePoints(List<ImportDataStep> steps) { System.out.println("多线程查询======== start"); List<Point> points = new ArrayList<>(); for (ImportDataStep step : steps) { Future<List<Point>> future = executorService.submit(new HighImportDataPointFuture(step, pointLogic)); try { points.addAll(future.get()); } catch (InterruptedException e) { e.printStackTrace(); } catch (ExecutionException e) { e.printStackTrace(); } } System.out.println("多线程查询======== point " + points.size() + " 条数=============="); return points; }
位于 HighImportDataServiceImpl 实现错误了吧,future.get()会阻塞线程 所以实际上是串行提交,没有线程并行 future.get()应该在任务提交之外的循环遍历获取吧
The text was updated successfully, but these errors were encountered:
@Override public List<Point> recordHandlePoints(List<ImportDataStep> steps) { System.out.println("多线程查询======== start"); List<Point> points = new ArrayList<>(); LinkedList<Future<List<Point>>> tasks=new LinkedList<>(); for (ImportDataStep step : steps) { tasks.add(executorService.submit(new HighImportDataPointFuture(step, pointLogic))); } while (!tasks.isEmpty()){ try { points.addAll(tasks.pollFirst().get()); } catch (InterruptedException e) { e.printStackTrace(); } catch (ExecutionException e) { e.printStackTrace(); } } System.out.println("多线程查询======== point " + points.size() + " 条数=============="); return points; }
建议修改代码
Sorry, something went wrong.
future替换成completablefuture之后,改使用allof才是正解.
No branches or pull requests
位于 HighImportDataServiceImpl 实现错误了吧,future.get()会阻塞线程 所以实际上是串行提交,没有线程并行
future.get()应该在任务提交之外的循环遍历获取吧
The text was updated successfully, but these errors were encountered: