Code example for Semaphore

Methods: release

0
        return this.semaphore.tryAcquire(this.covertToItemLength(length), timeout, unit);
    } 
 
 
    public void releaseByLenth(int length) {
        this.semaphore.release(this.covertToItemLength(length));
    } 
 
 
    public int getWindowsSize() { 
        return itemUnitSize;
    } 
 
 
    private int covertToItemLength(int length) {
        return this.itemUnit.covertToItemLength(length);
    } 
 
    interface ItemUnit { 
        int covertToItemLength(int lenth);
    }