From: http://www.ibm.com/developerworks/cn/java/l-threadPool/
During software developmentProgramMutual communication is often required. For example, when several threads Add a message to the queue, while the other thread needs to wake up the thread to process things during sleep. In this case, the semaphore must be used for synchronization. Createsemaphore is the creation of semaphores, and releasesemaphore is the addition of semaphores. Semaphore is another synchronization problem mechanism. Whether it is event or mutex, when other processes hold waitforsingleobject, it depends on whether the current object is signal or unsignal and determines whether to wait, and semaphore is the same, but it will change to the signal/unsignal status, but it is somewhat different. It provides a Count value, which allows any thread that executes to waitforsingleobject within this Count value to not stop, andEach time waitforsingleobject is executed, the Count value is reduced by one.,When the Count value is 0, the semaphore is in the unsignal State, andWhen a thread releasesemaphore is created, the Count value is increased.So that other threads or signals of signal can be obtained, and waitforsingleobject stops waiting.