What is the difference between .Semaphore() and .BoundedSemaphore()?
问题 I know that threading.Lock() is equal to threading.Semaphore(1) . Is also threading.Lock() equal to threading.BoundedSemaphore(1) ? And newly I met threading.BoundedSemaphore() , what is the difference between these? such as the following code snippet (to apply limitation on threads): import threading sem = threading.Semaphore(5) sem = threading.BoundedSemaphore(5) 回答1: A Semaphore can be released more times than it's acquired, and that will raise its counter above the starting value. A