Is there a way to acquire a permit from any semaphore in a collection? Similar to select() in Unix I/O programming: you have collection of stream handles and wait for data in any of them.
I am not sure if this answer the question; the semaphore are useful for implementing kind of resource pooling in your case a pool of limited stream handler so you want to put a bound or limit on of the size of stream handlers ( ELEMENTS IN THE COLLECTION) so that if this bound is being exceeded the caller
thread to pull more will block until an available resource ( stream handler) is returned into the collection. In your case, you have a bounded collection and at the same time
your element (stream handler ) will block i.e will be in a wait state until an event happens
Collection of ServerSocket of size n which listen to different ports is an ideal sample of example which I will try to simulate if you would like me to continue
Hope this could help.