1

我设置了quartz.net 来运行几个预定的作业和几个轮询作业。轮询作业可以包含可能需要 10 分钟的运行代码。这些作业从用户操作排队(因此可能有 x 个用户操作的队列)。我已经安排了当时必须运行的工作。但是,这些线程都可能被长时间运行的轮询作业用完。有没有办法为轮询作业永远不会使用的计划任务指定线程?

我知道线程优先级,但是如果其他线程已在使用中,这并不能保证计划的作业将运行。

谢谢你的帮助。

4

2 回答 2

2

另一个建议是,当工作触发时,关闭另一个线程来完成工作,这样您就可以将工作线程返回到 Quartz 池。

为工作线程使用有界线程池,这样您就不会同时运行太多工作线程。

请参阅 Executor 和 ThreadPool 类的 java.util.concurrent。这是一个更复杂的解决方案,但可能会更好地扩展。

于 2010-03-01T14:38:37.470 回答
1

You're right. If the threads are all running jobs, your scheduled jobs won't run at the scheduled time.

AFAIK there is no way to reserve a thread for certain jobs. If you want to stick to quartz to run the schduled job, you could set up a separate Quartz instance to run the scheduled jobs and then set the thread pool size to a number that would guarantee that there will always be some thread available to run.

于 2010-01-07T17:37:58.257 回答