Adds counting semaphores

An attempt on implementation of counting semaphores requested in Issue #162 , both mutex and java implementations should be working

Two questions about ```reduce_permits```:
first, in Java it is a protected method used (according to the docs[1])  ``` in subclasses that use semaphores to track resources that become unavailable```. Is this method needed?

second, does it make sense to raise an error if doing the reduce would bring available permits below zero? Another approach would be to reduce available permits to zero if anyone attempted to do this

[1] https://docs.oracle.com/javase/7/docs/api/java/util/concurrent/Semaphore.html#reducePermits(int)
@pitr-ch I believe that in your example `old` needs to be declared outside the block else its scope will only be within the block:

```ruby
def drain_permits
   old = 0
   @mutex.synchronize { old, @free = @free, 0 }
   old
end
```

@adamruzicka If you have a free moment over the next few days, can you please test these variations? I know it may seem somewhat pedantic, but we've learned that these minor variations can often hide troubling concurrency bugs.