Mercurial Hosting > luan
diff src/goodjava/lucene/logging/LoggingIndexWriter.java @ 1502:8a7b6b32c691
minor threads
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Sun, 10 May 2020 22:48:15 -0600 |
parents | e66e3d50b289 |
children | f443542d8650 |
line wrap: on
line diff
--- a/src/goodjava/lucene/logging/LoggingIndexWriter.java Sun May 10 22:28:13 2020 -0600 +++ b/src/goodjava/lucene/logging/LoggingIndexWriter.java Sun May 10 22:48:15 2020 -0600 @@ -13,6 +13,8 @@ import java.util.List; import java.util.ArrayList; import java.util.Random; +import java.util.concurrent.Executors; +import java.util.concurrent.ExecutorService; import org.apache.lucene.document.Document; import org.apache.lucene.index.DirectoryReader; import org.apache.lucene.index.IndexReader; @@ -43,6 +45,7 @@ private static final int OP_ADD_DOCUMENT = 3; private static final int OP_UPDATE_DOCUMENT = 4; private static final Random rnd = new Random(); + protected static final ExecutorService threadPool = Executors.newCachedThreadPool(); public final LuceneIndexWriter indexWriter; private final File logDir; @@ -343,7 +346,7 @@ } if( logs.size() > 3 ) { isMerging = true; - new Thread(mergeLogs).start(); + threadPool.execute(mergeLogs); // mergeLogs.run(); } }