首页 > 代码库 > 状态的所有权

状态的所有权

A semaphore initialized to one, and which is used such that it only has at most one permit available, can serve as a mutual exclusion

lock. This is more commonly known as a binary semaphore, because it only has two states: one permit available, or zero permits

available. When used in this way, the binary semaphore has the property (unlike many Lock implementations), that the "lock" can be

released by a thread other than the owner (as semaphores have no notion of ownership). This can be useful in some specialized

contexts, such as deadlock recovery.

状态的所有权