信号量优先 [英] Semaphore with priority

查看:105
本文介绍了信号量优先的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道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?

推荐答案

来自

没有保证的订单,例如 FIFO或LIFO,其中阻塞了线程 输入信号量.

There is no guaranteed order, such as FIFO or LIFO, in which blocked threads enter the semaphore.

但是看看这两个都支持线程优先级的项目.

But take a look at these two projects which both supports priority for threads.

智能线程池

C#中的线程安全优先级队列

这篇关于信号量优先的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆