I am developing Java REST Web Service using Spring and Hibernate. I need to implement a feature to schedule a future task. For example, When User Sign Up in my application I have to credit him 100 virtual credits to his account for first six months. Like this there is some more similar features.
I am thinking like TimerTask
can be used for this feature. The problem is If I create Timer
for each users who sign up, I can't able to stop Timer
of specific user if he goes inactive and it seems like dumping Thread in memory. If 1000 users sign up there will be 1000 TimerTask
Threads.
How to implement this kind of feature using Spring or Java? I should have the full control over the Thread, I can able to stop thread If I want.