IsaacLevon
IsaacLevon

Reputation: 2580

Why do Spring offer its own task executors?

Why do we need AsyncTaskExecutor (and it's implementations, i.e. SimpleAsyncTaskExecutor), when Java offers those already (through Executors)?

Upvotes: 2

Views: 108

Answers (2)

Andrew
Andrew

Reputation: 49646

TaskExecutoris basically a Spring abstraction over the standard JDK's Executor.

Equivalent to JDK 1.5's java.util.concurrent.Executor interface; extending it now in Spring 3.0, so that clients may declare a dependency on an Executor and receive any TaskExecutor implementation.

The Javadoc of org.springframework.core.task.TaskExecutor

Spring guys build own ecosystem and care how it can coexist with the standard JDK means. Usually, these implementations are more competitive, API-richer and Spring-orientated (actively used within the Spring Framework itself).

Upvotes: 3

Adam Siemion
Adam Siemion

Reputation: 16039

SimpleAsyncTaskExecutor is an implementation of AsyncTaskExecutor, which is by default used when running @Async methods. You can however provide your own TaskExecutor to be used instead of the default one. The reason why Spring does it is to give you more flexibility.

Upvotes: 2

Related Questions