Reputation: 329
I'm writing a service that will call REST service every x seconds. I could do that with EJB @Schedule annotation as well as with ScheduledExecutorService.
which one is better to use? and why?
Upvotes: 1
Views: 290
Reputation: 2280
If you're writing an EJB application, you should use Schedule
- the EJB spec demands that EJBs should not use threads directly, and says that doing so may cause errors in the container, as well as preventing the container from managing resources efficiently.
In exchange, with Schedule
you get the benefits of container management and EJB services.
Upvotes: 2