This is an automated email from the ASF dual-hosted git repository.
koji pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/opennlp.git
The following commit(s) were added to refs/heads/master by this push:
new 7bb8759 OPENNLP-1224 Use Daemon threads (#338)
7bb8759 is described below
commit 7bb8759d2921e39651102d36ccd8de200bf0f2b1
Author: Edd Spencer <[email protected]>
AuthorDate: Wed Nov 14 05:27:22 2018 +0000
OPENNLP-1224 Use Daemon threads (#338)
---
.../main/java/opennlp/tools/cmdline/PerformanceMonitor.java | 8 ++++++--
.../src/main/java/opennlp/tools/ml/maxent/GISTrainer.java | 9 ++++++++-
.../tools/ml/maxent/quasinewton/ParallelNegLogLikelihood.java | 10 +++++++++-
3 files changed, 23 insertions(+), 4 deletions(-)
diff --git
a/opennlp-tools/src/main/java/opennlp/tools/cmdline/PerformanceMonitor.java
b/opennlp-tools/src/main/java/opennlp/tools/cmdline/PerformanceMonitor.java
index 082b27c..f7a869e 100644
--- a/opennlp-tools/src/main/java/opennlp/tools/cmdline/PerformanceMonitor.java
+++ b/opennlp-tools/src/main/java/opennlp/tools/cmdline/PerformanceMonitor.java
@@ -36,8 +36,12 @@ import java.util.concurrent.TimeUnit;
*/
public class PerformanceMonitor {
- private ScheduledExecutorService scheduler =
- Executors.newScheduledThreadPool(1);
+ private ScheduledExecutorService scheduler =
Executors.newScheduledThreadPool(1, runnable -> {
+ Thread thread = new Thread(runnable);
+ thread.setName("opennlp.tools.cmdline.PerformanceMonitor");
+ thread.setDaemon(true);
+ return thread;
+ });
private final String unit;
diff --git
a/opennlp-tools/src/main/java/opennlp/tools/ml/maxent/GISTrainer.java
b/opennlp-tools/src/main/java/opennlp/tools/ml/maxent/GISTrainer.java
index e8f6177..19d2c63 100644
--- a/opennlp-tools/src/main/java/opennlp/tools/ml/maxent/GISTrainer.java
+++ b/opennlp-tools/src/main/java/opennlp/tools/ml/maxent/GISTrainer.java
@@ -481,7 +481,14 @@ public class GISTrainer extends AbstractEventTrainer {
/* Estimate and return the model parameters. */
private void findParameters(int iterations, double correctionConstant) {
int threads = modelExpects.length;
- ExecutorService executor = Executors.newFixedThreadPool(threads);
+
+ ExecutorService executor = Executors.newFixedThreadPool(threads, runnable
-> {
+ Thread thread = new Thread(runnable);
+
thread.setName("opennlp.tools.ml.maxent.ModelExpactationComputeTask.nextIteration()");
+ thread.setDaemon(true);
+ return thread;
+ });
+
CompletionService<ModelExpectationComputeTask> completionService =
new ExecutorCompletionService<>(executor);
double prevLL = 0.0;
diff --git
a/opennlp-tools/src/main/java/opennlp/tools/ml/maxent/quasinewton/ParallelNegLogLikelihood.java
b/opennlp-tools/src/main/java/opennlp/tools/ml/maxent/quasinewton/ParallelNegLogLikelihood.java
index 36cacb3..2429d00 100644
---
a/opennlp-tools/src/main/java/opennlp/tools/ml/maxent/quasinewton/ParallelNegLogLikelihood.java
+++
b/opennlp-tools/src/main/java/opennlp/tools/ml/maxent/quasinewton/ParallelNegLogLikelihood.java
@@ -104,7 +104,15 @@ public class ParallelNegLogLikelihood extends
NegLogLikelihood {
* Compute tasks in parallel
*/
private void computeInParallel(double[] x, Class<? extends ComputeTask>
taskClass) {
- ExecutorService executor = Executors.newFixedThreadPool(threads);
+
+ ExecutorService executor = Executors.newFixedThreadPool(threads, runnable
-> {
+ Thread thread = new Thread(runnable);
+ thread.setName(
+
"opennlp.tools.ml.maxent.quasinewton.ParallelNegLogLikelihood.computeInParallel()");
+ thread.setDaemon(true);
+ return thread;
+ });
+
int taskSize = numContexts / threads;
int leftOver = numContexts % threads;