Accessing scoped proxy beans within Threads of

后端 未结 4 1234
庸人自扰
庸人自扰 2020-12-02 13:45

I have a web application running in tomcat where I\'m using a ThreadPool (Java 5 ExecutorService) to run IO intensive operations in parallel to improve performance. I would

4条回答
  •  离开以前
    2020-12-02 14:24

    Spring has a ThreadPoolTaskExecutor class that you can use to manage your thread pool from Spring. However, it looks like you'd have to do some work to make the Spring context available to each thread.

    I'm not sure if it will work even if you do wire it up this way though. Spring uses a token in thread local to locate objects in request (or session) scope, so if you're trying to access a request scope bean from a different thread, it's likely that token won't be there.

提交回复
热议问题