Code example for Semaphore

Methods: acquirerelease

0
	} 
 
	protected abstract V doRun(); 
 
	public void waitForCompletion() throws InterruptedException { 
		s.acquire();
		s.release();
	} 
 
	public boolean isComplete() throws InterruptedException { 
		return s.tryAcquire(10, TimeUnit.MILLISECONDS);
	} 
 
	public V getValue() throws Exception { 
		s.acquire();
		s.release();
		if (exception != null)
			throw exception;
		return value;
	} 
Connect your IDE to all the code out there  Get Codota for Java