Code example for ReentrantLock

Methods: isHeldByCurrentThread, unlock

0
		 * Release the lock previously taken 
		 */ 
		public void releaseExclusiveLock() { 
			//final Thread t = Thread.currentThread(); 
			//System.out.println(t.getName() + " releasing EXCLUSIVE lock"); 
			if (!mLock.isHeldByCurrentThread())
				throw new RuntimeException("Exclusive Lock is not held by this thread");
			mLock.unlock();
			//System.out.println("Release lock held by " + mLock.getHoldCount()); 
			//System.out.println(t.getName() + " released EXCLUSIVE lock"); 
		} 
	} 
	 
	/** 
	 * Database wrapper class that performs thread synchronization on all operations. 
	 *  
	 * @author Philip Warner 
	 */ 
	public static class SynchronizedDb { 
		/** Underlying database */ 
		final SQLiteDatabase mDb;