Code example for Semaphore

Methods: acquireUninterruptiblyrelease

0
	public DefaultMailbox() { 
		this(new LinkedList<RequestType>());
	} 
 
	public void add(RequestType message) {
		sem.acquireUninterruptibly();
		try { 
			queue.add(message);
		} finally { 
			sem.release();
		} 
	} 
	 
	public RequestType poll() { 
		sem.acquireUninterruptibly();
		try { 
			return queue.poll();
		} finally { 
			sem.release();
		} 
Experience pair programming with AI  Get Codota for Java