Code example for ReentrantLock

Methods: newCondition

	 * @author Philip Warner 
	public static class Synchronizer { 
		/** Main lock for synchronization */ 
		private final ReentrantLock mLock = new ReentrantLock();
		/** Condition fired when a reader releases a lock */ 
		private final Condition mReleased = mLock.newCondition();
		/** Collection of threads that have shared locks */ 
		private final Hashtable<Thread,Integer> mSharedOwners = new Hashtable<Thread,Integer>();
		/** Lock used to pass back to consumers of shared locks */ 
		private final SharedLock mSharedLock = new SharedLock();
		/** Lock used to pass back to consumers of exclusive locks */ 
		private final ExclusiveLock mExclusiveLock = new ExclusiveLock();
		/** Enum of lock types supported */ 
		public enum LockTypes { shared, exclusive };
		 * Interface common to all lock types. 
Experience pair programming with AI  Get Codota for Java