Skip to content

Instantly share code, notes, and snippets.

@kylec32
Created August 17, 2022 15:05
Show Gist options
  • Save kylec32/a28de4e096fc542e4ee2b13c1236f108 to your computer and use it in GitHub Desktop.
Save kylec32/a28de4e096fc542e4ee2b13c1236f108 to your computer and use it in GitHub Desktop.
public void process(ExecutorService executorService) {
long startTime = System.currentTimeMillis();
try (ExecutorService executor = executorService) {
for (String url : getUrls()) {
executor.execute(() -> {
try {
new URL("https://" + url).getContent();
System.out.println("Finished processing: " + url);
} catch (IOException e) {
}
});
}
}
System.out.println("Processing time: " + (System.currentTimeMillis() - startTime)/1000.0f + " seconds");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment