You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@groovy.apache.org by su...@apache.org on 2021/06/13 05:21:29 UTC

[groovy] branch master updated: Apply thread factory to ginq thread pool

This is an automated email from the ASF dual-hosted git repository.

sunlan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/groovy.git


The following commit(s) were added to refs/heads/master by this push:
     new 1e521a8  Apply thread factory to ginq thread pool
1e521a8 is described below

commit 1e521a875f1da9efb7eeadf9adb17d62d3b8382a
Author: Daniel Sun <su...@apache.org>
AuthorDate: Sun Jun 13 13:20:13 2021 +0800

    Apply thread factory to ginq thread pool
---
 .../ginq/provider/collection/runtime/QueryableHelper.groovy  | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/subprojects/groovy-ginq/src/main/groovy/org/apache/groovy/ginq/provider/collection/runtime/QueryableHelper.groovy b/subprojects/groovy-ginq/src/main/groovy/org/apache/groovy/ginq/provider/collection/runtime/QueryableHelper.groovy
index 62bee8f..192464f 100644
--- a/subprojects/groovy-ginq/src/main/groovy/org/apache/groovy/ginq/provider/collection/runtime/QueryableHelper.groovy
+++ b/subprojects/groovy-ginq/src/main/groovy/org/apache/groovy/ginq/provider/collection/runtime/QueryableHelper.groovy
@@ -23,6 +23,7 @@ import groovy.transform.CompileStatic
 import java.util.concurrent.CompletableFuture
 import java.util.concurrent.ExecutorService
 import java.util.concurrent.Executors
+import java.util.concurrent.ThreadFactory
 import java.util.concurrent.TimeUnit
 import java.util.function.Function
 import java.util.function.Supplier
@@ -126,7 +127,16 @@ class QueryableHelper {
     private QueryableHelper() {}
 
     private static class ThreadPoolHolder {
-        static final ExecutorService THREAD_POOL = Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors())
+        static final ExecutorService THREAD_POOL = Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors(), new ThreadFactory() {
+            private int seq
+            @Override
+            Thread newThread(Runnable r) {
+                Thread t = new Thread(r)
+                t.setName("ginq-thread-" + seq++)
+                t.setDaemon(true)
+                return t
+            }
+        })
         private ThreadPoolHolder() {}
     }
 }