Think about how not to restrict connections (or anything) with Semaphore.
So you might think, "That sounds stupid." But, this simplifies my code a bit, as it allows me to treat limited and unlimited cases evenly.
Note. I am not looking for advice on how to write something like
if(limited) { semaphore.acquire(); }
I can come up with dozens of ways to do this with if statements.
In particular, I'm looking for Apache Commons or a Java solution. This is just a simple situation where I can write my own simple class to solve it, but when there are widely available utilities, I prefer to use them.
djechlin
source share