Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rationalise ThreadPoolTaskExecutor and ScheduledExecutorFactoryBean [SPR-5337] #10010

Closed
spring-projects-issues opened this issue Dec 3, 2008 · 1 comment
Assignees
Labels
type: enhancement A general enhancement
Milestone

Comments

@spring-projects-issues
Copy link
Collaborator

Kenny MacLeod opened SPR-5337 and commented

There is currently a gap in functionality between ThreadPoolTaskExecutor, which is offers lots of ways of configuring a ThreadPoolExecutor but hides it behind a TaskExecutor facade, and SheduledExecutorFactoryBean, which generates a ScheduledThreadPoolExecutor and is a FactoryBean.

It feels like these two should be brought together somehow. I've created a subclass ThreadPoolTaskExecutor which implements FactoryBean and exposes the native ThreadPoolExecutor. I think that SheduledExecutorFactoryBean could itself just be a subclass of ThreadPoolTaskExecutor, but which overrides the method which creates the executor instance.

So, how about a class called ThreadPoolExecutorFactory, which provides facilities for configuring and instantiating ThreadPoolExecutor instances, and then a variety of subclasses of this, including ThreadPoolTaskExecutor (which wraps the ThreadPoolExecutor in a TaskExecutor facade), and ThreadPoolExecutorFactoryBean (which exposes the ThreadPoolExecutor directly). SheduledExecutorFactoryBean would simply become a special case of ThreadPoolExecutorFactoryBean.


Affects: 2.5.6

@spring-projects-issues
Copy link
Collaborator Author

Juergen Hoeller commented

I've added a ThreadPoolExecutorFactoryBean (exposing the native ExecutorService API) analogous to ScheduledExecutorFactoryBean (exposing the native ScheduledExecutorService API). Both share a common base class with configuration properties now.

ThreadPoolTaskExecutor continues to exist as a JMX-capable Spring TaskExecutor implementation, using a ThreadPoolExecutor underneath but with different design tradeoffs in terms of being a Spring component.

Note that Spring 3.0 has plenty of further concurrency enhancements: TaskExecutor extends Executor now; AsyncTaskExecutor has "Future submit(Runnable)" and "Future submit(Callable)" methods; we ship an ExecutorServiceAdapter class as a standard wrapper for a Spring TaskExecutor; etc.

Juergen

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

2 participants