C# 中信号量的初始计数和最大计数意味着什么
我试图了解如何在 C# 中使用信号量,我知道信号量在初始化时接受两个参数信号量(初始计数,最大计数)。但我不太明白这些参数的含义。我用一个类比来理解它,
想象一间只有一个隔间的浴室,这样一次只能供一个人使用。卫生间外面已经排起了长队。使用这个类比你可以解释初始计数和最大计数的含义吗?
I'm trying to understand how to use semaphores in c#, I know semaphores accept two parameters when initializing it Semaphore(initial count, maximum count). But I don't fully understand what the parameters mean. Here's an analogy I'm using to understand it
Imagine a bathroom with only one stall so that way it's only possible for one person to use it at a time. There's a queue outside the bathroom. using this analogy can you explain what the initial count and maximum count mean.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
最大计数是浴室中可用的隔间数量,初始计数是浴室中当前可用的隔间数量。
Maximum count is the available number of stalls in your bathroom and initial count is the number of currently available stalls in your bathroom.