diff --git a/source/net/filebot/web/LocalSearch.java b/source/net/filebot/web/LocalSearch.java index a5f591f7..1a560f99 100644 --- a/source/net/filebot/web/LocalSearch.java +++ b/source/net/filebot/web/LocalSearch.java @@ -25,6 +25,8 @@ import com.ibm.icu.text.Transliterator; public class LocalSearch { + private static final ExecutorService localThreadPool = Executors.newWorkStealingPool(); + private final AbstractStringMetric metric = new QGramsDistance(); private float resultMinimumSimilarity = 0.5f; private int resultSetSize = 20; @@ -66,21 +68,16 @@ public class LocalSearch { }); } - ExecutorService executor = Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors()); final List> resultSet = new ArrayList>(objects.size()); - try { - for (Future> entry : executor.invokeAll(tasks)) { - if (entry.get() != null) { - resultSet.add(entry.get()); - } - - if (Thread.interrupted()) { - throw new InterruptedException(); - } + for (Future> entry : localThreadPool.invokeAll(tasks)) { + if (entry.get() != null) { + resultSet.add(entry.get()); + } + + if (Thread.interrupted()) { + throw new InterruptedException(); } - } finally { - executor.shutdownNow(); } // sort by similarity descending (best matches first)