diff --git a/jpos/src/main/java/org/jpos/q2/QBeanSupport.java b/jpos/src/main/java/org/jpos/q2/QBeanSupport.java index 52074af1ef..02f6d0367c 100644 --- a/jpos/src/main/java/org/jpos/q2/QBeanSupport.java +++ b/jpos/src/main/java/org/jpos/q2/QBeanSupport.java @@ -255,8 +255,9 @@ protected void stopService() throws Exception {} protected void destroyService() throws Exception {} protected synchronized ScheduledThreadPoolExecutor getScheduledThreadPoolExecutor() { + int corePoolSize = cfg.getInt("stpe-core-pool-size", 1); if (scheduledThreadPoolExecutor == null) - scheduledThreadPoolExecutor = ConcurrentUtil.newScheduledThreadPoolExecutor(); + scheduledThreadPoolExecutor = ConcurrentUtil.newScheduledThreadPoolExecutor(corePoolSize); return scheduledThreadPoolExecutor; } diff --git a/jpos/src/main/java/org/jpos/util/ConcurrentUtil.java b/jpos/src/main/java/org/jpos/util/ConcurrentUtil.java index 83767401ad..a6ec978902 100644 --- a/jpos/src/main/java/org/jpos/util/ConcurrentUtil.java +++ b/jpos/src/main/java/org/jpos/util/ConcurrentUtil.java @@ -23,7 +23,10 @@ public class ConcurrentUtil { public static ScheduledThreadPoolExecutor newScheduledThreadPoolExecutor() { - ScheduledThreadPoolExecutor stpe = new ScheduledThreadPoolExecutor(1, + return newScheduledThreadPoolExecutor(1); + } + public static ScheduledThreadPoolExecutor newScheduledThreadPoolExecutor(int corePoolSize) { + ScheduledThreadPoolExecutor stpe = new ScheduledThreadPoolExecutor(corePoolSize, r -> { Thread t = Executors.defaultThreadFactory().newThread(r); t.setDaemon(true);