Skip to content

Instantly share code, notes, and snippets.

@kitskub
Created August 7, 2013 19:15
Show Gist options
  • Select an option

  • Save kitskub/6177476 to your computer and use it in GitHub Desktop.

Select an option

Save kitskub/6177476 to your computer and use it in GitHub Desktop.
ExecutorService threads = Executors.newCachedThreadPool();
for (final T elem : elements) {
threads.submit(new Runnable() {
@Override
public void run() {
operation.invoke(elem);
}
});
}
if (blocking) {
threads.awaitTermination(long timeout, TimeUnit unit)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment