Code example for Semaphore

Methods: drainPermits

0
                event.release();
        } 
    } 
 
    public void Reset() { 
        event.drainPermits();
    } 
 
    public void WaitOne() throws InterruptedException { 
        event.acquire();
    } 
 
    public boolean WaitOne(int timeOut, TimeUnit unit) throws InterruptedException {
        return event.tryAcquire(timeOut, unit);
    } 
 
    public boolean isSignalled() { 
        return event.availablePermits() > 0;
    } 
}