[jira] [Resolved] (OPENNLP-1224) Use Daemon threads in executor services

2018-11-13 Thread Koji Sekiguchi (JIRA)


 [ 
https://issues.apache.org/jira/browse/OPENNLP-1224?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Koji Sekiguchi resolved OPENNLP-1224.
-
   Resolution: Fixed
Fix Version/s: 1.9.1

> Use Daemon threads in executor services
> ---
>
> Key: OPENNLP-1224
> URL: https://issues.apache.org/jira/browse/OPENNLP-1224
> Project: OpenNLP
>  Issue Type: Improvement
>Reporter: Edd Spencer
>Assignee: Koji Sekiguchi
>Priority: Major
> Fix For: 1.9.1
>
>
> For all executor services it would be ideal if they are configured to use 
> daemon threads. This will mean that should the process need to be shutdown it 
> will not wait until these threads are complete in order to do so (which can 
> take a long time depending on operation).



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (OPENNLP-1224) Use Daemon threads in executor services

2018-11-13 Thread ASF GitHub Bot (JIRA)


[ 
https://issues.apache.org/jira/browse/OPENNLP-1224?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16686104#comment-16686104
 ] 

ASF GitHub Bot commented on OPENNLP-1224:
-

kojisekig closed pull request #338: OPENNLP-1224 Daemon threads
URL: https://github.com/apache/opennlp/pull/338
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

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 082b27c75..f7a869e98 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 @@
  */
 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 e8f61774a..19d2c635e 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 GISModel trainModel(int iterations, DataIndexer di, 
Prior modelPrior, int
   /* 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 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 36cacb3ab..2429d001c 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 double valueAt(double[] x) {
* Compute tasks in parallel
*/
   private void computeInParallel(double[] x, Class 
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;
 


 


This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


> Use Daemon threads in executor services
> ---
>
> Key: OPENNLP-1224
> URL: https://issues.apache.org/jira/browse/OPENNLP-1224
> Project: OpenNLP
>  Issue Type: Improvement
>Reporter: Edd Spencer
>Assignee: Koji Sekiguchi
>Priority: Major
>
> For all executor services it would be ideal if they are configured to use 
> daemon threads. This will mean that should the process need to be shutdown it 
> will not wait until these threads are complete in order to do so (which can 
> take a long time depending on operation).



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (OPENNLP-1224) Use Daemon threads in executor services

2018-11-13 Thread ASF GitHub Bot (JIRA)


[ 
https://issues.apache.org/jira/browse/OPENNLP-1224?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16686103#comment-16686103
 ] 

ASF GitHub Bot commented on OPENNLP-1224:
-

kojisekig commented on issue #338: OPENNLP-1224 Daemon threads
URL: https://github.com/apache/opennlp/pull/338#issuecomment-438541536
 
 
   Thank you, Edd! I'm sorry for late reply. We've talked about this last week 
among committers. This is very nice contribution! I'll merge this soon.


This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


> Use Daemon threads in executor services
> ---
>
> Key: OPENNLP-1224
> URL: https://issues.apache.org/jira/browse/OPENNLP-1224
> Project: OpenNLP
>  Issue Type: Improvement
>Reporter: Edd Spencer
>Assignee: Koji Sekiguchi
>Priority: Major
>
> For all executor services it would be ideal if they are configured to use 
> daemon threads. This will mean that should the process need to be shutdown it 
> will not wait until these threads are complete in order to do so (which can 
> take a long time depending on operation).



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Assigned] (OPENNLP-1224) Use Daemon threads in executor services

2018-11-13 Thread Koji Sekiguchi (JIRA)


 [ 
https://issues.apache.org/jira/browse/OPENNLP-1224?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Koji Sekiguchi reassigned OPENNLP-1224:
---

Assignee: Koji Sekiguchi

> Use Daemon threads in executor services
> ---
>
> Key: OPENNLP-1224
> URL: https://issues.apache.org/jira/browse/OPENNLP-1224
> Project: OpenNLP
>  Issue Type: Improvement
>Reporter: Edd Spencer
>Assignee: Koji Sekiguchi
>Priority: Major
>
> For all executor services it would be ideal if they are configured to use 
> daemon threads. This will mean that should the process need to be shutdown it 
> will not wait until these threads are complete in order to do so (which can 
> take a long time depending on operation).



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)