java.util.concurrent.ExecutorService.invokeAny()方法的使用及代码示例

x33g5p2x  于2022-01-17 转载在 其他  
字(5.4k)|赞(0)|评价(0)|浏览(125)

本文整理了Java中java.util.concurrent.ExecutorService.invokeAny()方法的一些代码示例,展示了ExecutorService.invokeAny()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ExecutorService.invokeAny()方法的具体详情如下:
包路径:java.util.concurrent.ExecutorService
类名称:ExecutorService
方法名:invokeAny

ExecutorService.invokeAny介绍

[英]Executes the given tasks, returning the result of one that has completed successfully (i.e., without throwing an exception), if any do. Upon normal or exceptional return, tasks that have not completed are cancelled. The results of this method are undefined if the given collection is modified while this operation is in progress.
[中]执行给定的任务,返回已成功完成的任务的结果(即,不引发异常),如果有的话。正常或异常返回后,未完成的任务将被取消。如果在执行此操作时修改了给定集合,则此方法的结果是未定义的。

代码示例

代码示例来源:origin: redisson/redisson

@Override
public <T> T invokeAny(Collection<? extends Callable<T>> tasks, long timeout, TimeUnit unit) throws
    InterruptedException, ExecutionException, TimeoutException {
  return delegate.invokeAny(tasks, timeout, unit);
}

代码示例来源:origin: redisson/redisson

@Override
public <T> T invokeAny(Collection<? extends Callable<T>> tasks) throws InterruptedException, ExecutionException {
  return delegate.invokeAny(tasks);
}

代码示例来源:origin: SonarSource/sonarqube

@Override
public <T> T invokeAny(Collection<? extends Callable<T>> tasks,
 long timeout,
 TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException {
 return delegate.invokeAny(tasks, timeout, unit);
}

代码示例来源:origin: bumptech/glide

@Override
public <T> T invokeAny(
  @NonNull Collection<? extends Callable<T>> tasks,
  long timeout,
  @NonNull TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException {
 return delegate.invokeAny(tasks, timeout, unit);
}

代码示例来源:origin: bumptech/glide

@NonNull
@Override
public <T> T invokeAny(@NonNull Collection<? extends Callable<T>> tasks)
  throws InterruptedException, ExecutionException {
 return delegate.invokeAny(tasks);
}

代码示例来源:origin: google/guava

@Override
public <T> T invokeAny(Collection<? extends Callable<T>> tasks)
  throws InterruptedException, ExecutionException {
 return delegate().invokeAny(tasks);
}

代码示例来源:origin: google/guava

@Override
public final <T> T invokeAny(Collection<? extends Callable<T>> tasks)
  throws InterruptedException, ExecutionException {
 return delegate.invokeAny(wrapTasks(tasks));
}

代码示例来源:origin: google/guava

@Override
public final <T> T invokeAny(Collection<? extends Callable<T>> tasks, long timeout, TimeUnit unit)
  throws InterruptedException, ExecutionException, TimeoutException {
 return delegate.invokeAny(wrapTasks(tasks), timeout, unit);
}

代码示例来源:origin: google/guava

@Override
public <T> T invokeAny(Collection<? extends Callable<T>> tasks, long timeout, TimeUnit unit)
  throws InterruptedException, ExecutionException, TimeoutException {
 return delegate().invokeAny(tasks, timeout, unit);
}

代码示例来源:origin: prestodb/presto

@Override
public <T> T invokeAny(Collection<? extends Callable<T>> tasks)
  throws InterruptedException, ExecutionException {
 return delegate().invokeAny(tasks);
}

代码示例来源:origin: prestodb/presto

@Override
public final <T> T invokeAny(Collection<? extends Callable<T>> tasks)
  throws InterruptedException, ExecutionException {
 return delegate.invokeAny(wrapTasks(tasks));
}

代码示例来源:origin: prestodb/presto

@Override
public <T> T invokeAny(Collection<? extends Callable<T>> tasks, long timeout, TimeUnit unit)
  throws InterruptedException, ExecutionException, TimeoutException {
 return delegate().invokeAny(tasks, timeout, unit);
}

代码示例来源:origin: prestodb/presto

@Override
public final <T> T invokeAny(Collection<? extends Callable<T>> tasks, long timeout, TimeUnit unit)
  throws InterruptedException, ExecutionException, TimeoutException {
 return delegate.invokeAny(wrapTasks(tasks), timeout, unit);
}

代码示例来源:origin: google/j2objc

@Override
public <T> T invokeAny(Collection<? extends Callable<T>> tasks)
  throws InterruptedException, ExecutionException {
 return delegate().invokeAny(tasks);
}

代码示例来源:origin: google/j2objc

@Override
public <T> T invokeAny(Collection<? extends Callable<T>> tasks, long timeout, TimeUnit unit)
  throws InterruptedException, ExecutionException, TimeoutException {
 return delegate().invokeAny(tasks, timeout, unit);
}

代码示例来源:origin: google/j2objc

@Override
public final <T> T invokeAny(Collection<? extends Callable<T>> tasks)
  throws InterruptedException, ExecutionException {
 return delegate.invokeAny(wrapTasks(tasks));
}

代码示例来源:origin: google/j2objc

@Override
public final <T> T invokeAny(Collection<? extends Callable<T>> tasks, long timeout, TimeUnit unit)
  throws InterruptedException, ExecutionException, TimeoutException {
 return delegate.invokeAny(wrapTasks(tasks), timeout, unit);
}

代码示例来源:origin: spring-projects/spring-security

@SuppressWarnings({ "rawtypes", "unchecked" })
public final Object invokeAny(Collection tasks) throws InterruptedException,
    ExecutionException {
  tasks = createTasks(tasks);
  return getDelegate().invokeAny(tasks);
}

代码示例来源:origin: SonarSource/sonarqube

@Test
public void invokeAny_delegates_to_executorService() throws ExecutionException, InterruptedException {
 underTest.invokeAny(CALLABLES);
 inOrder.verify(executorService).invokeAny(CALLABLES);
 inOrder.verifyNoMoreInteractions();
}

代码示例来源:origin: SonarSource/sonarqube

@Test
public void invokeAny1_delegates_to_executorService() throws InterruptedException, ExecutionException, TimeoutException {
 underTest.invokeAny(CALLABLES, SOME_LONG, SECONDS);
 inOrder.verify(executorService).invokeAny(CALLABLES, SOME_LONG, SECONDS);
 inOrder.verifyNoMoreInteractions();
}

相关文章