Quartz.Net 线程池

发布于 2024-08-17 11:00:28 字数 246 浏览 7 评论 0原文

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

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

感谢您的任何帮助。

I have quartz.net set up to run several scheduled jobs and several polling jobs. The polling jobs can consist of running code that can take 10 minutes. These jobs are queued from user actions (and so there could be a queue of x user actions).
I have scheuled jobs that HAVE to run at that time. However, the threads could all be used up by the long running polling jobs. Is there any way to have a designated thread for the scheduled tasks that will never be used by the polling jobs?

I am aware of the thread priority but this will not guarentee the scheduled job will run if the other threads are already in use.

Thanks for any help.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

忘东忘西忘不掉你 2024-08-24 11:00:28

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

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

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

Another suggestion, when the job fires, spin another thread off to do the work, so you can return the job thread to the Quartz pool.

Use a bounded thread pool for the worker threads, so you don't get too many worker threads running at the same time.

See, java.util.concurrent for the Executor and ThreadPool classes. It's a more complicated solution, but may scale better.

阳光下的泡沫是彩色的 2024-08-24 11:00:28

你说得对。如果线程都在运行作业,则您的计划作业将不会在计划时间运行。

AFAIK 无法为某些作业保留线程。如果您想坚持使用quartz来运行计划作业,您可以设置一个单独的Quartz实例来运行计划作业,然后将线程池大小设置为一个数字,以保证始终有一些线程可以运行。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文