lightrek
lightrek

Reputation: 981

Which one is better: Java ScheduledExecutorService or Spring framework @Scheduled

I am adding code to existing project written based on Spring framework. So wondering which one I should choose: Java ScheduledExecutorService or Spring framework @Scheduled ?

I see another post, which claims using spring framework version, but I don't quite understand the reason. What I think is if use ScheduledExecutorService , it looks like more under my control than the Spring framework @Scheduled.

Upvotes: 0

Views: 980

Answers (1)

Sashi
Sashi

Reputation: 2425

If you are already using Spring framework in your project, then you might as well schedule your task using @Scheduled annotation because it is easy to set it up compared to Java's ScheduledExecutorService.

But if your project doesn't use Spring framework, I'd just stick to Java's version of Scheduler.

Upvotes: 4

Related Questions