Problem with using Semaphore to protect queue
问题 I am using following code to limit use of resources. Once in a while(after 3-4 days of successful run) I get queue empty exception or the returned object is found to be null. I am wondering if I am limiting only 5 threads to enter this Get method, how come this happens. The places where GetConnection is called, ReleaseConnection is also definitely called within the Finally block. With each call, I am also logging no. of resources in the queue. The queue count never seems to be going more than