gpt4 book ai didi

c# - 保证信号量顺序?

转载 作者:太空狗 更新时间:2023-10-29 19:40:11 26 4
gpt4 key购买 nike

documentation对于 .NET Semaphore 类声明:

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

在这种情况下,如果我想要保证订单(先进先出或后进先出),我有哪些选择?这是不容易做到的事情吗?我必须编写自己的信号量吗?我认为那会非常先进?

谢谢,

史蒂夫

最佳答案

参见 this :

The FifoSemaphore works exactly like a normal Semaphore but also guarantees that tokens are served out to acquirers in the order that they manage to acquire the internal lock. The usage of a FifoSemaphore is identical to a Semaphore.

关于c# - 保证信号量顺序?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2553982/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com