The answer depends on whether you need to segregate application resources between different types of activity or not.
For example, I am currently writing a server application consisting of a few high-throughput writers and potentially many readers. Readers will access the app sporadically but could potentially request a lot of data (i.e. long running requests). I need to ensure that writers are never starved so am going to use two thread pools in my design for reading / writing. If the reader thread pool is temporarily exhausted the writers will be unaffected; only read requests will be delayed.
An alternative would have been to use a PriorityQueue in conjunction with a ThreadPoolExecutor and assign a higher priority to write requests.
So in conclusion - My advice would be: Start off with one thread pool and only make your design more complex if there's a concrete reason for doing so.
It's not really a direct answer, but another proposal :-(
Your Quartz jobs can be paused, canceled and so on, let's call it "managed". I guess you will create some UI to manage them.
Do you realize that you your other jobs ("on demand") will not benefit from the same functionalities, unless you implement it of course? Did you consider making everything a quartz job (even if it starts immediatly), to get a uniform code?
发布评论
评论(2)
答案取决于您是否需要在不同类型的活动之间隔离应用程序资源。
例如,我目前正在编写一个服务器应用程序,该应用程序由一些高吞吐量编写器和潜在的许多读取器组成。读者将偶尔访问该应用程序,但可能会请求大量数据(即长时间运行的请求)。我需要确保编写者永远不会挨饿,因此我将在我的设计中使用两个线程池进行读/写。如果读取器线程池暂时耗尽,写入器将不受影响;只有读请求会被延迟。
另一种选择是将
PriorityQueue
与ThreadPoolExecutor
结合使用,并为写入请求分配更高的优先级。总之,我的建议是:从一个线程池开始,只有在有具体原因的情况下才使您的设计变得更加复杂。
The answer depends on whether you need to segregate application resources between different types of activity or not.
For example, I am currently writing a server application consisting of a few high-throughput writers and potentially many readers. Readers will access the app sporadically but could potentially request a lot of data (i.e. long running requests). I need to ensure that writers are never starved so am going to use two thread pools in my design for reading / writing. If the reader thread pool is temporarily exhausted the writers will be unaffected; only read requests will be delayed.
An alternative would have been to use a
PriorityQueue
in conjunction with aThreadPoolExecutor
and assign a higher priority to write requests.So in conclusion - My advice would be: Start off with one thread pool and only make your design more complex if there's a concrete reason for doing so.
这并不是一个真正的直接答案,而是另一个建议:-(
你的 Quartz 作业可以暂停、取消等等,我们称之为“托管”。我想你会创建一些 UI 来管理它们。
您是否意识到您的其他工作(“按需”)不会从相同的功能中受益,除非您当然实现它?您是否考虑过让一切都成为石英工作(即使它立即开始) ),得到统一的代码?
It's not really a direct answer, but another proposal :-(
Your Quartz jobs can be paused, canceled and so on, let's call it "managed". I guess you will create some UI to manage them.
Do you realize that you your other jobs ("on demand") will not benefit from the same functionalities, unless you implement it of course? Did you consider making everything a quartz job (even if it starts immediatly), to get a uniform code?