Code example for ReadWriteLock

Methods: readLock

0
	public void reduce(long quantity) throws InterruptedException {
		add(-quantity);
	} 
 
	public long getUnits() throws InterruptedException { 
		lock.readLock().lockInterruptibly();
		try { 
			return units;
		} finally { 
			lock.readLock().unlock();
		} 
	} 
 
	@Override 
	public Stock prototype(int initial) {
		return new StockOwnedReadWriteLock(initial);
	} 
 
}