Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the purpose of TaskExecutor in spring?

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

like image 224
user2434 Avatar asked Oct 30 '25 23:10

user2434


2 Answers

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.

...

like image 134
ruhsuzbaykus Avatar answered Nov 02 '25 12:11

ruhsuzbaykus


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

like image 29
Boris Pavlović Avatar answered Nov 02 '25 12:11

Boris Pavlović



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!