Java 线程库
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5938461/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Thread Library for Java
提问by user489041
Anyone know of a good threading library for Java. Only real requirement for it is I need to modify the scheduler. Might have more requirements later so customization would be nice. Any advice or info on your experience with them would be great.
任何人都知道一个很好的 Java 线程库。唯一真正的要求是我需要修改调度程序。以后可能会有更多要求,所以定制会很好。关于您与他们的体验的任何建议或信息都会很棒。
Thanks
谢谢
回答by BertNase
Have a look at java.util.concurrent
package: Package introduction documentation. It should have everything you need.
看看java.util.concurrent
包:包介绍文档。它应该有你需要的一切。
回答by Karthik Ramachandran
I would also suggest you stick with java.util.concurrent
. You can modify how threads are scheduled for execution to a limited extend by implementing a custom ExecutorService
.
我也建议你坚持使用java.util.concurrent
. 您可以通过实现自定义ExecutorService
.
If you're going to be doing any serious work with the concurrent package, I highly recommend Brian Goetz's book Java Concurrency in Practice.
如果您打算对并发包进行任何认真的工作,我强烈推荐 Brian Goetz 的书Java Concurrency in Practice。
回答by Wesley Hartford
If the java.util.concurrent
package does not satisfy your requirements, Quartzis a great, open source, scheduler which allows you to schedule jobs for repeated execution, along with a whole lot of advanced features like fail-over, load-balancing, etc. I've used it for years and love it, but if java.util.concurrent
will meet your needs, stick with that.
如果java.util.concurrent
包不能满足您的要求,Quartz是一个很棒的开源调度程序,它允许您安排重复执行的作业,以及大量高级功能,如故障转移、负载平衡等。我已经使用它多年并喜欢它,但如果java.util.concurrent
能满足您的需求,请坚持下去。