I've got to write an app that performs a series of tasks:
What are the pros and cons of using plain java.util.timer Vs. Quartz for this?
Are there any other alternatives I should be considering?
For one, Quartz is more extendable. When you create a need for cron like jobs, quartz allready has the support for this. The threads that are used by your application are also managed by quartz, so you don't have to be starting your own thread. It is nice that this is handled by the Quartz Scheduler. It also integrates with the spring framework (don't know if that is applicable in your case). Quartz has reasonable documentation and is backed by a community.
Don't really know if the java.util.Timer is really used in Enterprise environments, but this depends on your application.
I am personally using Quartz + persistent storage for a Web application where triggers can be created interactively and should survive restarts, using Spring's scheduling abstraction. Both APIs IMHO lack an important concept: retrying failed tasks after a certain period of time. Adding this for myself was a pain for repeated tasks that should be retried as well.
an update: now (in 2014) with the advent of inbuilt java schedulers in Java 1.6, 1.7,.... i think quartz is less of a choice.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With