是一个没有公平的DelayQueue有问题吗? [英] Is a DelayQueue without fairness problematic?
本文介绍了是一个没有公平的DelayQueue有问题吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在Java 7中,DelayQueue的实现使用ReentrantLock,而没有公平策略。这是长远的问题吗?
感谢
解决方案
你考虑 ScheduledThreadPoolExecutor
(或任何其他生产者/消费者情况),工作线程是独立的,因此应该是 DelayQueue
。所以,没有:线程允许采取/轮询的顺序不起作用。
In Java 7 the implementation of DelayQueue uses a ReentrantLock without a fairness policy. Is this a problem in the long run? Can a thread starve because of this?
Thanks
解决方案
If you consider the ScheduledThreadPoolExecutor
(or any other producer/consumer situation), the worker threads are independent and so should be the jobs in the DelayQueue
. So, no: the order in which threads are allowed to take/poll does not make a difference.
这篇关于是一个没有公平的DelayQueue有问题吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文