Tag: invoke

Java:带有Callables的ExecutorService:invokeAll()和future.get() – 结果是否正确?

我使用Java中的ExecutorService来调用带有invokeAll()线程。 之后,我使用future.get()获取结果集。 以我创建线程的相同顺序收到结果非常重要。 这是一个片段: try { final List threads = new ArrayList(); // create threads for (String name : collection) { final CallObject object = new CallObject(name); threads.add(object); } // start all Threads results = pool.invokeAll(threads, 3, TimeUnit.SECONDS); for (Future future : results) { try { // this method blocks until it receives the result, […]