Many posts said we can use ScheduledExecutorService
in a ServletContextListener
. But I want to start a timer at some kind of circumstance, and then stop it at another circumstance. For example, start a timer in request A from client A, stop it in request B from client A or client B. Should I store the timer in session or not?
The real problem is this: I create an order from a web request, I wanna cancel the order if it hasn't been paid after 24 hours.
To make things clear, I suppose the situation like this: I create an object from a web request, I wanna delete the object if it hasn't been handled after 10 seconds. In such little time, was it good to run a schedule job like each 5 or 8 seconds? I wanna do the job precisely after 10 seconds or even 1 second.