I want to make a background service in java and I have a function to periodically check the database. If there's no email to be sent it will sleep for a few minutes and if there's an email to be sent it will run the function and send the email to the user.
My question is, which approach should I use: Schedule
or ExecutorService
and what are the advantages if I use them.
Note Update*
- I'm developing in JavaEE and use the JSF framework