Skip to content

Commit

Permalink
Merge pull request #559 from sumeetphadnis/master
Browse files Browse the repository at this point in the history
Allow setting of a higher `corePoolSize` while creating new `ScheduledThreadPoolExecutor`
  • Loading branch information
ar authored Aug 9, 2023
2 parents 9b0024f + b0b3669 commit 8febf01
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
3 changes: 2 additions & 1 deletion jpos/src/main/java/org/jpos/q2/QBeanSupport.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
5 changes: 4 additions & 1 deletion jpos/src/main/java/org/jpos/util/ConcurrentUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 8febf01

Please sign in to comment.