Code example for Lock

Methods: newCondition

0
		} 
		return false; 
	} 
 
	private static Lock lock = new ReentrantLock();
	private static Condition threadCond = lock.newCondition();
 
	public static boolean lock(Context ctx) {
		// 99% goes here 
		if (tryLock(ctx))
			return true; 
		 
		// Unfortunately goes here, then we will wait until the lock is released 
		lock.lock();
		LockContentObserver observer = new LockContentObserver(new Handler());
		ctx.getContentResolver().registerContentObserver(
				Uri.withAppendedPath(TMessage.AUTHORITY_URI, "locked")/*Uri.parse("content://tmessage/locked")*/, true,
				new LockContentObserver(null) { 
				}); 
		try { 
			threadCond.await();