anserini
anserini copied to clipboard
Refactor ThreadPoolExecutor to use try-with-resources
We use ThreadPools in many places throughout the codebase, e.g., https://github.com/castorini/anserini/blob/master/src/main/java/io/anserini/search/HnswDenseSearcher.java
Best practices starting Java 19 I believe is to use try-with-resources blocks, e.g., https://docs.oracle.com/en/java/javase/19/docs/api/java.base/java/util/concurrent/ExecutorService.html
try (ExecutorService e = Executors.newWorkStealingPool()) {
// submit or execute many tasks with e ...
}