I am using Timertask in my web application to launch a background thread once every 24 hrs every day at midnight. So I have a ServletContextListener and in contextInitialized, I create a Timertask object timertask(say) and a Timer object say t.
I call
t.schedule(timertask, firstTime.getTime(), rescheduleMiliSec);
where firstTime.getTime() = midnight and rescheduleMiliSec = 24 hr.
The thread launches fine and does what it is supposed to do in DIT.Every 24 hrs it launches the background task.
When it moves to PROD, the thread runs only once when context is initialised but not after that.
Is there any specific setting that might be the cause for this?
Is it possible your TimerTask implementation is throwing a RuntimeException?
If not an exception, then some TimerTask being scheduled in that Timer is blocking indefinitely. Those are the only two conditions that I am aware of that could cause a Timer to fail.
BTW, you might want to look into a ScheduledExecutorService. That is the more modern way of scheduling tasks.