当一个石英作业触发时,它是一个新的作业类实例吗? [英] when a quartz job fires, is it a new job class instance?

查看:111
本文介绍了当一个石英作业触发时,它是一个新的作业类实例吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对Quartz很新,我对作业生命周期有些怀疑。

I am very new to Quartz and I have some doubts about the jobs lifecycle.

假设我有一个工作被配置为做一些事情。

Let's suppose I have a single job configured to do some stuff.

这项工作开始并结束其工作。当它再次触发它是同一个实例(可能设置为睡眠并由调度程序唤醒)或者它是一个新的作业实例(一旦作业结束它就被杀死,当再次满足触发条件时,创建一个新的作业实例) ?

The job fires and ends its work. When it fires again is it the same instance (maybe set to sleep and awaken by the scheduler) or is it a new job instance (once the job ends it is killed and when the trigger condition is met again a new job instance is created)?

我问这样的问题,因为当我调试我的应用程序(带有石英支持的Spring 3 mvc)时,我看到了新的作业实例和使用SimpleThreadPool的新线程$ WorkerThreadRun()每次激活该作业时都会打开,以便SimpleThreadPool $ WorkerThreadRun()线程被堆积起来并且永不终止。

I ask such question because when I debug my application (spring 3 mvc with quartz support) I see new instances of the job and new threads with SimpleThreadPool$WorkerThreadRun() opened for every time the job is fired so that the SimpleThreadPool$WorkerThreadRun() threads are piled up and never terminated.

我只是想知道这种行为是否正常或是我一定会填满记忆; - )

I just want to know if this behaviour is allright or I'm bound to fill the memory ;-)

有谁可以给​​我一些解释?在此先感谢。

Can anyone give me some explanation? Thanks in advance.

推荐答案

每次想要触发该作业时,Quartz都会创建新作业类的实例。假设您有数十万个作业被安排在非常频繁地触发 - 将所有这些作业保留在内存中会浪费内存。

Quartz creates new instance of your job class every time it wants to trigger that job. Suppose you have hundreds of thousands of jobs scheduled to trigger very infrequently - it would be a waste of memory to keep all those jobs in memory.

但是如果您正在使用< a href =http://static.springsource.org/spring/docs/current/spring-framework-reference/html/scheduling.html#scheduling-quartz =noreferrer> Spring支持Quartz ,尤其是 MethodInvokingJobDetailFactoryBean ,Spring将处理你的作业的生命周期(它基本上调用你的一个bean的指定方法)。但是在您的应用程序中似乎并非如此。

However if you are using Spring support for Quartz, especially the MethodInvokingJobDetailFactoryBean, Spring will handle the lifecycle of your job (it basically calls designated method of one of your beans). But seems not to be the case in your application.

当然,在作业完成后没有其他引用指向它(这是正常情况)垃圾收集器最终将释放作业占用的内存。)

Of course after the job is done and no other references are pointing to it (which is the normal case) garbage collector will eventually release the memory occupied by the job).

最后关于线程 - Quartz创建一个固定的工作线程池(参见 org.quartz.threadPool.threadCount 配置选项) 。每次运行作业时,Quartz都可能决定使用不同的线程 - 但是每次触发都不会创建新的线程。

Finally about threads - Quartz creates a fixed pool of worker threads (see org.quartz.threadPool.threadCount configuration option). Every time you run a job Quartz may decide to use a different thread - but it won't create new thread per every trigger.

这篇关于当一个石英作业触发时,它是一个新的作业类实例吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆