Reputation: 691
Can anyone tell,advice how to run a scheduler without Quartz in java. I want to implement such features that if application server remain stop , my scheduler will run. So I thought the executable class to place outside of the war file. So can anyone give me suggestion ? Thanks.
Upvotes: 1
Views: 848
Reputation: 7662
Regarding scheduling tasks without Quartz
, you can use Java's ScheduledExecutorService:
ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1);
final Runnable beeper = new Runnable() {
public void run() { System.out.println("beep"); }
};
// Beeps every 10 seconds
scheduler.scheduleAtFixedRate(beeper, 0, 10, TimeUnit.SECONDS);
Now, regarding doing it when your application is not running, I see three options:
Upvotes: 1