简体   繁体   English

Quartz线程池和任务执行器之间的区别

[英]Difference between Quartz Thread Pool and Task Executor

I'm working in Spring-quartz batch. 我正在春季石英批处理中。 I'm trying to implement Multi-threading for the Batch application. 我正在尝试为批处理应用程序实现多线程。

I come across 2 possible way of multi threading, 我遇到了两种可能的多线程方法,

  1. Use Quartz Thread pool 使用Quartz线程池
  2. Use Task Executors. 使用任务执行器。

I used Quartz thread pool and it is working fine but was wondering what the advantage i will get if i also implement task Executor. 我使用了Quartz线程池,它工作正常,但想知道如果我还实现任务执行器,我将获得什么好处。

I'm doing all this as xml configuration. 我将所有这些作为xml配置进行。

Please suggest me which should be used and what is the benefit of one over the other. 请建议我应该使用哪个,一个相对于另一个有什么好处。

Thanks 谢谢

I would choose task executors if all you need is to keep N workers picking pieces of work from the common queue. 如果您只需要让N个工作人员从公共队列中挑选工作,我就选择任务执行程序。 The advantage is that you do not need any external libraries for this. 这样做的好处是您不需要任何外部库。 Quartz thread pool was created before Java 5 - that is why it exists. Quartz线程池是在Java 5之前创建的-这就是它存在的原因。

Executor is good enough for running concurrent tasks within a JVM. 执行程序足以在JVM中运行并发任务。 But if you want to distribute tasks across multiple JVMs in a clustered environment, then you should explore Quartz using the JDBC Store. 但是,如果要在集群环境中的多个JVM之间分配任务,则应使用JDBC存储探索Quartz。 Quartz is more of a scheduling framework where you can setup jobs to run on a periodic basis. Quartz更像是一个调度框架,您可以在其中设置作业以定期运行。 But I have also used it heavily for concurrent programming. 但是我也将其大量用于并发编程。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM