What is the purpose of TaskExecutor in spring?

混江龙づ霸主 提交于 2019-12-11 02:36:36

问题


What is the purpose of TaskExecutor in spring. What problem does it solve ? How is it different from Executors in java concurrent package ?


回答1:


From http://static.springsource.org/spring/docs/2.0.8/reference/scheduling.html

23.4. The Spring TaskExecutor abstraction

...

Spring's TaskExecutor interface is identical to the java.util.concurrent.Executor interface. In fact, its primary reason for existence is to abstract away the need for Java 5 when using thread pools. The interface has a single method execute(Runnable task) that accepts a task for execution based on the semantics and configuration of the thread pool.

...




回答2:


It's an interface whose implementations wrap around Java 5+ ExecutorService and provide implementations for previous versions of Java that are missing the package java.util.concurrent



来源:https://stackoverflow.com/questions/8209864/what-is-the-purpose-of-taskexecutor-in-spring

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!