Java Bean的作用域请求存在多线程问题

Java Bean的作用域请求存在多线程问题,java,multithreading,spring-boot,java-8,parallel-processing,Java,Multithreading,Spring Boot,Java 8,Parallel Processing,当前在使用线程和以下代码的并行流时面临问题 private ThreadPoolTaskExecutor executor Future<List<Boolean>> resList = executor.submit(()->requestIds.parallelStream().map(id->completeTask(id)).collect(Collectors.toList())); List<Boolean>

当前在使用
线程
和以下代码的并行流时面临问题

private ThreadPoolTaskExecutor executor

Future<List<Boolean>> resList = executor.submit(()->requestIds.parallelStream().map(id->completeTask(id)).collect(Collectors.toList()));
            List<Boolean> resultList = resList.get();

RequestContextListener
用于Spring启动应用程序

请添加正确的错误堆栈跟踪,如果您正在使用Spring,请注意。添加了错误,这是spring boot应用程序在处理请求的线程中不使用请求范围的bean。我无法更改该bean的范围,因为它在中的许多其他方法中使用project@user4886675您是使用ThreadPoolTaskExecutor对象作为Springbean还是普通java对象。ThreadPoolTaskExecutor也应该作为SpringBean创建,并且应该出现在SpringApplicationContext中,例如
@bean公共TaskExecutor executor(){ThreadPoolTaskExecutor=new ThreadPoolTaskExecutor();executor.setCorePoolSize(4);executor.setMaxPoolSize(4);executor.setThreadNamePrefix(“默认任务执行器线程”);executor.initialize();return executor;}
Error : java.lang.IllegalStateException: No thread-bound request found: Are you referring to request attributes outside of an actual web request, or processing a request outside of the originally receiving thread? If you are actually operating within a web request and still receive this message, your code is probably running outside of DispatcherServlet/DispatcherPortlet: In this case, use RequestContextListener or RequestContextFilter to expose the current request.