p;* @see #invokeAll(List, long) */ public List<Node> invokeAll(List<ValidationTask> tasks) { return invokeAll(tasks, DEFAULT_TASK_TIMEOUT * tasks.size()); } /** * 在线程池中执行所有给定的任务并取回运行结果 * * @param timeout 以毫秒为单位的超时时间,小于0表示不设定超时 * @see java.util.concurrent.ExecutorService#invokeAll(java.util.Collection) */ public List<Node> invokeAll(List<ValidationTask> tasks, long timeout) { List<Node> nodes = new ArrayList<Node>(tasks.size()); try { List<Future<Node>> futures = null; if (timeout < 0) { futures = executorService.invokeAll(tasks); } else { futures = executorService.invokeAll(tasks, timeout, TimeUnit.MILLISECONDS); } for (Future<Node> future : futures) { try { nodes.add(future.get()); } catch (ExecutionException e) { e.printStackTrace(); } } } catch (InterruptedException e) { e.printStackTrace(); } return nodes; } /** * 关闭当前ExecutorService * * @param timeout 以毫秒为单位的超时时间 */ public void destoryExecutorService(long timeout) { if (executorService != null && !executorService.isShutdown()) { try { executorService.awaitTermination(timeout, TimeUnit.MILLISECONDS); } catch (InterruptedException e) { e.printStackTrace(); } &n