具有优先级的信号量
我知道 System.Threading 命名空间中的 Semaphore 类,但我不知道它是否允许等待线程具有不同的优先级。
如果两个线程正在等待一个空位,有没有办法让优先级较高的线程拥有第一个空位?
I know about the Semaphore
class in the System.Threading
namespace, but I don't see if it allows waiting threads to have different priorities levels.
If two threads are waiting for an open slot, is there a way to allow the thread with the higher priority to have the first open slot available?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
来自 Semaphore 类的 MSDN 文档
但是看看这两个项目,它们都支持线程优先级。
智能线程池
C# 中的线程安全优先级队列
From the MSDN documentantion on the Semaphore class
But take a look at these two projects which both supports priority for threads.
Smart Thread Pool
Thread-safe priority queue in C#