我正在努力创造一种"种类的"服务器中的调度程序使用预期来自用户的输入(日/月/年)的servlet,并在日历到达当天时执行该事件。
我通过Java为我的servlet使用ScheduledExecutorService实现了这一点。
{{1}}
但是,我认为这可能会加载我的servlet(因为它是一个将运行x天直到它到达最后一天的线程)。 你能提出一种更有效的不同方法或不同的方法吗?
谢谢!
答案 0 :(得分:0)
这个怎么样:
1. dump all the incoming tasks to a DB.
2. fetch the tasks from DB periodically:
E.G., fetch the tasks from DB every day for daily tasks.
3. put those tasks into your scheduler. You will have threads running up to the interval you setup.
E.G., if you fetch them daily, then it will be maximum 24 hours.