mirror of https://github.com/apache/lucene.git
Preallocate idle threads for the executor.
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1296112 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
ac5e508766
commit
6f9388d6d8
|
@ -40,9 +40,7 @@ import java.util.Map.Entry;
|
|||
import java.util.Random;
|
||||
import java.util.Set;
|
||||
import java.util.TimeZone;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.*;
|
||||
|
||||
import org.apache.lucene.analysis.Analyzer;
|
||||
import org.apache.lucene.codecs.Codec;
|
||||
|
@ -1427,9 +1425,16 @@ public abstract class LuceneTestCase extends Assert {
|
|||
return ret;
|
||||
} else {
|
||||
int threads = 0;
|
||||
final ExecutorService ex = (random.nextBoolean()) ? null
|
||||
: Executors.newFixedThreadPool(threads = _TestUtil.nextInt(random, 1, 8),
|
||||
new NamedThreadFactory("LuceneTestCase"));
|
||||
final ThreadPoolExecutor ex;
|
||||
if (random.nextBoolean()) {
|
||||
ex = null;
|
||||
} else {
|
||||
threads = _TestUtil.nextInt(random, 1, 8);
|
||||
ex = new ThreadPoolExecutor(threads, threads, 0L, TimeUnit.MILLISECONDS,
|
||||
new LinkedBlockingQueue<Runnable>(),
|
||||
new NamedThreadFactory("LuceneTestCase"));
|
||||
ex.prestartAllCoreThreads();
|
||||
}
|
||||
if (ex != null) {
|
||||
if (VERBOSE) {
|
||||
System.out.println("NOTE: newSearcher using ExecutorService with " + threads + " threads");
|
||||
|
|
Loading…
Reference in New Issue