-
Notifications
You must be signed in to change notification settings - Fork 465
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5672 from TomasHofman/WFCORE-6505
WFCORE-6505 Avoid creating duplicate thread groups on server reload
- Loading branch information
Showing
12 changed files
with
69 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,8 @@ | |
package org.jboss.as.threads; | ||
|
||
import java.security.PrivilegedAction; | ||
import java.util.Map; | ||
import java.util.concurrent.ConcurrentHashMap; | ||
import java.util.concurrent.ThreadFactory; | ||
import org.jboss.msc.service.Service; | ||
import org.jboss.msc.service.StartContext; | ||
|
@@ -19,6 +21,9 @@ | |
* @author <a href="mailto:[email protected]">David M. Lloyd</a> | ||
*/ | ||
public final class ThreadFactoryService implements Service<ThreadFactory> { | ||
|
||
private static final Map<String, ThreadGroup> THREAD_GROUP_CACHE = new ConcurrentHashMap<>(); | ||
|
||
private String threadGroupName; | ||
private Integer priority; | ||
private String namePattern; | ||
|
@@ -50,7 +55,8 @@ public synchronized void setNamePattern(final String namePattern) { | |
|
||
@Override | ||
public synchronized void start(final StartContext context) throws StartException { | ||
final ThreadGroup threadGroup = (threadGroupName != null) ? new ThreadGroup(threadGroupName) : null; | ||
final ThreadGroup threadGroup = THREAD_GROUP_CACHE.computeIfAbsent(threadGroupName, name -> | ||
name != null ? new ThreadGroup(name) : null); | ||
value = doPrivileged(new PrivilegedAction<ThreadFactory>() { | ||
public ThreadFactory run() { | ||
return new JBossThreadFactory(threadGroup, Boolean.FALSE, priority, namePattern, null, null); | ||
|