开发者

Is there something opposite to Semaphore

Is there something opposite to Semaphore? I am looking for something system-wide process-independant that I could use to count how much threads are 开发者_C百科using a resource, and not so much limit how much threads are using a resource. Or should I consider using a semaphore with a pretty high maximum count?


Semaphores can be released or acquired in any order. I would recommend that you simply release the semaphore when your thread starts using the resource and acquire it when done with the resource.

This is assuming you need cross-process communication. If you don;t, by all means use a counter variable.

May I ask why you're doing this?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜