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

Time:02-27

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.

CodePudding user response:

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.

  • Related