diff --git a/lucene/CHANGES.txt b/lucene/CHANGES.txt
index 4942b7f40d8..2fe4021d30d 100644
--- a/lucene/CHANGES.txt
+++ b/lucene/CHANGES.txt
@@ -169,6 +169,10 @@ New features
process the payloads of the segments as they are merged (e.g. if one wants to
rewrite payloads of external indexes as they are added, or of local ones).
(Shai Erera, Michael Busch, Mike McCandless)
+
+* LUCENE-2440: Add support for custom ExecutorService in
+ ParallelMultiSearcher (Edward Drapkin via Mike McCandless)
+
======================= Lucene 3.x (not yet released) =======================
diff --git a/lucene/src/java/org/apache/lucene/search/ParallelMultiSearcher.java b/lucene/src/java/org/apache/lucene/search/ParallelMultiSearcher.java
index c5b42077691..595e201c9a0 100644
--- a/lucene/src/java/org/apache/lucene/search/ParallelMultiSearcher.java
+++ b/lucene/src/java/org/apache/lucene/search/ParallelMultiSearcher.java
@@ -42,19 +42,25 @@ import org.apache.lucene.util.ThreadInterruptedException;
* or {@link #search(Query,Filter,int)} methods.
*/
public class ParallelMultiSearcher extends MultiSearcher {
-
private final ExecutorService executor;
private final Searchable[] searchables;
private final int[] starts;
- /** Creates a {@link Searchable} which searches searchables. */
+ /** Creates a {@link Searchable} which searches searchables with the default
+ * executor service (a cached thread pool). */
public ParallelMultiSearcher(Searchable... searchables) throws IOException {
+ this(Executors.newCachedThreadPool(new NamedThreadFactory(ParallelMultiSearcher.class.getSimpleName())), searchables);
+ }
+
+ /**
+ * Creates a {@link Searchable} which searches searchables with the specified ExecutorService.
+ */
+ public ParallelMultiSearcher(ExecutorService executor, Searchable... searchables) throws IOException {
super(searchables);
this.searchables = searchables;
this.starts = getStarts();
- executor = Executors.newCachedThreadPool(new NamedThreadFactory(this.getClass().getSimpleName()));
+ this.executor = executor;
}
-
/**
* Executes each {@link Searchable}'s docFreq() in its own thread and waits for each search to complete and merge
* the results back together.