Code example for ReadWriteLock

Methods: readLockwriteLock

0
	 
	public Train() 
	{ 
		this.remainingSeats = TOTALSEATS;
		rwLock = new ReentrantReadWriteLock(true);
		readLock = rwLock.readLock();
		writeLock = rwLock.writeLock();
	} 
	 
	public int getRemainingSeats() { 
		readLock.lock();
		try 
		{ 
			return remainingSeats;
		} 
		finally 
		{ 
			readLock.unlock();
		} 
	} 
Connect your IDE to all the code out there  Get Codota for Java