Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[14.0.x] ISPN-15147 DefaultExecutorFactory can create multiple ThreadGroups #11277

Merged
merged 1 commit into from
Sep 7, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ public ExecutorService getExecutor(Properties p, final AccessControlContext cont
if (blocking == null) {
threadGroup = Thread.currentThread().getThreadGroup();
} else {
threadGroup = Boolean.parseBoolean(blocking) ? new BlockingThreadFactory.ISPNBlockingThreadGroup(threadNamePrefix + "-group") :
new NonBlockingThreadFactory.ISPNNonBlockingThreadGroup(threadNamePrefix + "-group");
threadGroup = Boolean.parseBoolean(blocking) ? BlockingThreadGroupHolder.GROUP :
NonBlockingThreadGroupHolder.GROUP;
}
BlockingQueue<Runnable> queue = queueSize == 0 ? new SynchronousQueue<>()
: new LinkedBlockingQueue<>(queueSize);
Expand All @@ -70,4 +70,13 @@ public Thread newThread(Runnable r) {
return new ThreadPoolExecutor(coreThreads, maxThreads, keepAliveTime, TimeUnit.MILLISECONDS, queue, tf,
new ThreadPoolExecutor.CallerRunsPolicy());
}

// We use holder classes to not create groups that are not needed
static class BlockingThreadGroupHolder {
private static final ThreadGroup GROUP = new BlockingThreadFactory.ISPNBlockingThreadGroup("ISPN-blocking-group");
}

static class NonBlockingThreadGroupHolder {
private static final ThreadGroup GROUP = new NonBlockingThreadFactory.ISPNNonBlockingThreadGroup("ISPN-non-blocking-group");
}
}