Skip to content

Commit fa63fae

Browse files
committed
BAEL-442 Making some changes to how many threads are in the executors. Cleaning up some white space.
1 parent f221fac commit fa63fae

2 files changed

Lines changed: 13 additions & 17 deletions

File tree

‎spring-sleuth/src/main/java/com/baeldung/spring/session/SleuthController.java‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,4 @@ public String helloSleuthAsync() throws InterruptedException {
6565
logger.info("After Async Method Call");
6666
return "success";
6767
}
68-
69-
70-
7168
}

‎spring-sleuth/src/main/java/com/baeldung/spring/session/ThreadConfig.java‎

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,22 @@ public class ThreadConfig extends AsyncConfigurerSupport implements SchedulingCo
2525

2626
@Bean
2727
public Executor executor() {
28-
return makeExecutor();
28+
ThreadPoolTaskExecutor threadPoolTaskExecutor = new ThreadPoolTaskExecutor();
29+
threadPoolTaskExecutor.setCorePoolSize(1);
30+
threadPoolTaskExecutor.setMaxPoolSize(1);
31+
threadPoolTaskExecutor.initialize();
32+
33+
return new LazyTraceExecutor(beanFactory, threadPoolTaskExecutor);
2934
}
3035

3136
@Override
3237
public Executor getAsyncExecutor() {
33-
return makeExecutor();
38+
ThreadPoolTaskExecutor threadPoolTaskExecutor = new ThreadPoolTaskExecutor();
39+
threadPoolTaskExecutor.setCorePoolSize(1);
40+
threadPoolTaskExecutor.setMaxPoolSize(1);
41+
threadPoolTaskExecutor.initialize();
42+
43+
return new LazyTraceExecutor(beanFactory, threadPoolTaskExecutor);
3444
}
3545

3646
@Override
@@ -40,17 +50,6 @@ public void configureTasks(ScheduledTaskRegistrar scheduledTaskRegistrar) {
4050

4151
@Bean(destroyMethod = "shutdown")
4252
public Executor schedulingExecutor() {
43-
return Executors.newScheduledThreadPool(100);
53+
return Executors.newScheduledThreadPool(1);
4454
}
45-
46-
private Executor makeExecutor() {
47-
ThreadPoolTaskExecutor threadPoolTaskExecutor = new ThreadPoolTaskExecutor();
48-
threadPoolTaskExecutor.setCorePoolSize(5);
49-
threadPoolTaskExecutor.setMaxPoolSize(10);
50-
threadPoolTaskExecutor.initialize();
51-
52-
return new LazyTraceExecutor(beanFactory, threadPoolTaskExecutor);
53-
}
54-
55-
5655
}

0 commit comments

Comments
 (0)