diff --git a/li.strolch.agent/src/main/java/li/strolch/agent/api/StrolchAgent.java b/li.strolch.agent/src/main/java/li/strolch/agent/api/StrolchAgent.java index 84b309995..288cdca8c 100644 --- a/li.strolch.agent/src/main/java/li/strolch/agent/api/StrolchAgent.java +++ b/li.strolch.agent/src/main/java/li/strolch/agent/api/StrolchAgent.java @@ -29,10 +29,10 @@ import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.TimeUnit; import li.strolch.agent.impl.ComponentContainerImpl; -import li.strolch.runtime.ThreadPoolFactory; import li.strolch.runtime.configuration.ConfigurationParser; import li.strolch.runtime.configuration.RuntimeConfiguration; import li.strolch.runtime.configuration.StrolchConfiguration; +import li.strolch.utils.NamedThreadPoolFactory; import li.strolch.utils.dbc.DBC; import li.strolch.utils.helper.StringHelper; import li.strolch.utils.helper.SystemHelper; @@ -97,7 +97,7 @@ public class StrolchAgent { DBC.PRE.assertNotEmpty("poolName must be set!", poolName); ExecutorService executor = this.executors.get(poolName); if (executor == null) { - executor = Executors.newCachedThreadPool(new ThreadPoolFactory(poolName)); + executor = Executors.newCachedThreadPool(new NamedThreadPoolFactory(poolName)); this.executors.put(poolName, executor); } @@ -117,7 +117,7 @@ public class StrolchAgent { DBC.PRE.assertNotEmpty("poolName must be set!", poolName); ExecutorService executor = this.executors.get(poolName); if (executor == null) { - executor = Executors.newSingleThreadExecutor(new ThreadPoolFactory(poolName)); + executor = Executors.newSingleThreadExecutor(new NamedThreadPoolFactory(poolName)); this.executors.put(poolName, executor); } @@ -137,7 +137,7 @@ public class StrolchAgent { DBC.PRE.assertNotEmpty("poolName must be set!", poolName); ScheduledExecutorService executor = this.scheduledExecutors.get(poolName); if (executor == null) { - executor = Executors.newScheduledThreadPool(4, new ThreadPoolFactory(poolName)); + executor = Executors.newScheduledThreadPool(4, new NamedThreadPoolFactory(poolName)); this.scheduledExecutors.put(poolName, executor); } diff --git a/li.strolch.agent/src/main/java/li/strolch/runtime/ThreadPoolFactory.java b/li.strolch.utils/src/main/java/li/strolch/utils/NamedThreadPoolFactory.java similarity index 71% rename from li.strolch.agent/src/main/java/li/strolch/runtime/ThreadPoolFactory.java rename to li.strolch.utils/src/main/java/li/strolch/utils/NamedThreadPoolFactory.java index 9020d7102..139459daf 100644 --- a/li.strolch.agent/src/main/java/li/strolch/runtime/ThreadPoolFactory.java +++ b/li.strolch.utils/src/main/java/li/strolch/utils/NamedThreadPoolFactory.java @@ -1,19 +1,17 @@ -package li.strolch.runtime; +package li.strolch.utils; import java.util.concurrent.ThreadFactory; import java.util.concurrent.atomic.AtomicInteger; /** - * Simple {@link ThreadFactory} with which the thread pool name can be defined - * - * @see java.util.concurrent.Executors.DefaultThreadFactory + * Simple {@link ThreadFactory} which allocates as a pool and has a name for each pool */ -public class ThreadPoolFactory implements ThreadFactory { +public class NamedThreadPoolFactory implements ThreadFactory { private final ThreadGroup group; private final AtomicInteger threadNumber = new AtomicInteger(1); private final String poolName; - public ThreadPoolFactory(String poolName) { + public NamedThreadPoolFactory(String poolName) { SecurityManager s = System.getSecurityManager(); this.group = (s != null) ? s.getThreadGroup() : Thread.currentThread().getThreadGroup(); this.poolName = poolName + "-";