本文整理了Java中java.util.concurrent.ThreadPoolExecutor.invokeAll()
方法的一些代码示例,展示了ThreadPoolExecutor.invokeAll()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ThreadPoolExecutor.invokeAll()
方法的具体详情如下:
包路径:java.util.concurrent.ThreadPoolExecutor
类名称:ThreadPoolExecutor
方法名:invokeAll
暂无
代码示例来源:origin: lingochamp/FileDownloader
List<Future<Object>> subTaskFutures = DOWNLOAD_EXECUTOR.invokeAll(subTasks);
if (FileDownloadLog.NEED_LOG) {
for (Future<Object> future : subTaskFutures) {
代码示例来源:origin: rackerlabs/blueflood
retList = rollupExecutors.invokeAll(work);
} catch (InterruptedException e) {}
代码示例来源:origin: uk.org.retep.tools/annotations
public <T> List<Future<T>> invokeAll(
Collection<? extends Callable<T>> tasks,
long timeout,
TimeUnit unit )
throws InterruptedException
{
return executor.invokeAll( tasks, timeout, unit );
}
代码示例来源:origin: apache/oozie
public <T> List<Future<T>> invokeAll(List<CallableWrapper<T>> tasks)
throws InterruptedException {
return executor.invokeAll(tasks);
}
代码示例来源:origin: org.apache.oozie/oozie-core
public <T> List<Future<T>> invokeAll(List<CallableWrapper<T>> tasks)
throws InterruptedException {
return executor.invokeAll(tasks);
}
代码示例来源:origin: com.jtransc/jtransc-rt
@Override
public <T> List<Future<T>> invokeAll(Collection<? extends Callable<T>> tasks, long timeout, TimeUnit unit) throws InterruptedException {
return invokeAll(tasks);
}
代码示例来源:origin: de.dentrassi.eclipse.neoscada.utils/org.eclipse.scada.utils
@Override
public <T> List<Future<T>> invokeAll ( final Collection<? extends Callable<T>> tasks, final long timeout, final TimeUnit unit ) throws InterruptedException
{
final List<Future<T>> result = super.invokeAll ( tasks, timeout, unit );
updateCount ();
return result;
}
代码示例来源:origin: de.dentrassi.eclipse.neoscada.utils/org.eclipse.scada.utils
@Override
public <T> List<Future<T>> invokeAll ( final Collection<? extends Callable<T>> tasks ) throws InterruptedException
{
final List<Future<T>> result = super.invokeAll ( tasks );
updateCount ();
return result;
}
代码示例来源:origin: griddynamics/jagger
@Override
public <T> List<Future<T>> invokeAll(Collection<? extends Callable<T>> tasks) throws InterruptedException {
return delegate().invokeAll(tasks);
}
代码示例来源:origin: griddynamics/jagger
@Override
public <T> List<Future<T>> invokeAll(Collection<? extends Callable<T>> tasks, long timeout, TimeUnit unit) throws InterruptedException {
return delegate().invokeAll(tasks, timeout, unit);
}
代码示例来源:origin: BeelGroup/Docear-Desktop
public Collection<MetaData> search(String query, Set<Class<?>> useEngines, Map<ExtractorConfigKey, Object> options) throws MalformedConfigException, IOException{
Collection<MetaData> results = new ArrayList<MetaData>();
List<Callable<Collection<MetaData>>> extractors = getExtractors(query, useEngines, options, null);
try {
List<Future<Collection<MetaData>>> tasks = executor.invokeAll(extractors);
for(Future<Collection<MetaData>> task : tasks){
results.addAll(task.get());
}
} catch (InterruptedException e) {
logger.warn("Exception occured in blockedSearchThread", e);
} catch (ExecutionException e) {
Throwable t = e.getCause();
if(t != null && t instanceof IOException){
throw (IOException)t;
}
logger.warn("Exception occured in blockedSearchThread", e);
}
return results;
}
代码示例来源:origin: io.eventcenter/ec-api
protected ListenersConsumedResult executeListenerSources(AggregatorEventListener listener, List<CommonEventSource> sources,
ListenerExceptionHandler handler, ThreadPoolExecutor executor) throws InterruptedException {
long start = System.currentTimeMillis();
List<Future<ListenerConsumedResult>> tasks = executor.invokeAll(createListenerCallers(listener,sources,handler));
ListenersConsumedResult list = new ListenersConsumedResult();
for(Future<ListenerConsumedResult> task : tasks){
try {
list.getResults().add(task.get());
} catch (ExecutionException e) {
logger.error(e.getMessage(), e);
}
}
list.setTook(System.currentTimeMillis() - start);
return list;
}
代码示例来源:origin: com.github.steveash.mallet/mallet
public double getValue () {
if (cacheIndicator.isValueStale()) {
// compute values again
try {
// run all threads and wait for them to finish
List<Future<Double>> results = executor.invokeAll(valueTasks);
// compute final log probability
int batch = 0;
for (Future<Double> f : results) {
try {
batchCachedValue[batch++] = f.get();
} catch (ExecutionException ee) {
ee.printStackTrace();
}
}
} catch (InterruptedException ie) {
ie.printStackTrace();
}
double cachedValue = MatrixOps.sum(batchCachedValue);
logger.info("getValue() (loglikelihood, optimizable by label likelihood) =" + cachedValue);
return cachedValue;
}
return MatrixOps.sum(batchCachedValue);
}
代码示例来源:origin: org.apache.mahout/mahout-mrlegacy
public void batchTrain(Map<Vector, Vector> batch, boolean update, int numDocTopicsIters) {
while (true) {
try {
List<TrainerRunnable> runnables = Lists.newArrayList();
for (Map.Entry<Vector, Vector> entry : batch.entrySet()) {
runnables.add(new TrainerRunnable(readModel, null, entry.getKey(),
entry.getValue(), new SparseRowMatrix(numTopics, numTerms, true),
numDocTopicsIters));
}
threadPool.invokeAll(runnables);
if (update) {
for (TrainerRunnable runnable : runnables) {
writeModel.update(runnable.docTopicModel);
}
}
break;
} catch (InterruptedException e) {
log.warn("Interrupted during batch training, retrying!", e);
}
}
}
代码示例来源:origin: org.apache.mahout/mahout-mr
public void batchTrain(Map<Vector, Vector> batch, boolean update, int numDocTopicsIters) {
while (true) {
try {
List<TrainerRunnable> runnables = new ArrayList<>();
for (Map.Entry<Vector, Vector> entry : batch.entrySet()) {
runnables.add(new TrainerRunnable(readModel, null, entry.getKey(),
entry.getValue(), new SparseRowMatrix(numTopics, numTerms, true),
numDocTopicsIters));
}
threadPool.invokeAll(runnables);
if (update) {
for (TrainerRunnable runnable : runnables) {
writeModel.update(runnable.docTopicModel);
}
}
break;
} catch (InterruptedException e) {
log.warn("Interrupted during batch training, retrying!", e);
}
}
}
代码示例来源:origin: org.apache.mahout/mahout-core
public void batchTrain(Map<Vector, Vector> batch, boolean update, int numDocTopicsIters) {
while (true) {
try {
List<TrainerRunnable> runnables = Lists.newArrayList();
for (Map.Entry<Vector, Vector> entry : batch.entrySet()) {
runnables.add(new TrainerRunnable(readModel, null, entry.getKey(),
entry.getValue(), new SparseRowMatrix(numTopics, numTerms, true),
numDocTopicsIters));
}
threadPool.invokeAll(runnables);
if (update) {
for (TrainerRunnable runnable : runnables) {
writeModel.update(runnable.docTopicModel);
}
}
break;
} catch (InterruptedException e) {
log.warn("Interrupted during batch training, retrying!", e);
}
}
}
代码示例来源:origin: io.eventcenter/ec-api
protected ListenersConsumedResult executeListeners(List<AggregatorEventListener> listeners, CommonEventSource source, ListenerExceptionHandler handler, ThreadPoolExecutor executor) throws InterruptedException {
long start = System.currentTimeMillis();
List<Future<ListenerConsumedResult>> tasks = executor.invokeAll(createListenerCallers(listeners,source,handler));
ListenersConsumedResult list = new ListenersConsumedResult();
for(Future<ListenerConsumedResult> task : tasks){
try {
list.getResults().add(task.get());
} catch (ExecutionException e) {
logger.error(e.getMessage(), e);
}
}
list.setEventName(source.getEventName());
list.setSource(source);
list.setTook(System.currentTimeMillis() - start);
return list;
}
代码示例来源:origin: de.julielab/jcore-mallet-2.0.9
/**
* Returns the gradient, re-computes if gradient is stale. <p>
*
* *Note*: Assumes that <tt>buffer</tt> is already initialized.
*/
public void getValueGradient (double[] buffer) {
if (cacheIndicator.isGradientStale()) {
// compute values again if required
this.getValue();
// compute gradients again
try {
// run all threads and wait for them to finish
executor.invokeAll(gradientTasks);
} catch (InterruptedException ie) {
ie.printStackTrace();
}
}
optimizable.combineGradients(batchCachedGradient, buffer);
}
代码示例来源:origin: cc.mallet/mallet
/**
* Returns the gradient, re-computes if gradient is stale. <p>
*
* *Note*: Assumes that <tt>buffer</tt> is already initialized.
*/
public void getValueGradient (double[] buffer) {
if (cacheIndicator.isGradientStale()) {
// compute values again if required
this.getValue();
// compute gradients again
try {
// run all threads and wait for them to finish
executor.invokeAll(gradientTasks);
} catch (InterruptedException ie) {
ie.printStackTrace();
}
}
optimizable.combineGradients(batchCachedGradient, buffer);
}
代码示例来源:origin: com.github.steveash.mallet/mallet
/**
* Returns the gradient, re-computes if gradient is stale. <p>
*
* *Note*: Assumes that <tt>buffer</tt> is already initialized.
*/
public void getValueGradient (double[] buffer) {
if (cacheIndicator.isGradientStale()) {
// compute values again if required
this.getValue();
// compute gradients again
try {
// run all threads and wait for them to finish
executor.invokeAll(gradientTasks);
} catch (InterruptedException ie) {
ie.printStackTrace();
}
}
optimizable.combineGradients(batchCachedGradient, buffer);
}
内容来源于网络,如有侵权,请联系作者删除!