/** * Method "tryLock". * * @param key * @return {@code true} if the lock was free and was acquired by the current thread, or the lock * was already held by the current thread; and {@code false} otherwise * @throws InterruptedException * @throws IllegalArgumentException if bean is null * @see java.util.concurrent.locks.ReentrantLock#tryLock() */ @Override public boolean tryLock(final KP key) { blockOperationIfRequired(); incrementRunningOperations(); try { return locker.tryLock(key); } finally { decrementRunningOperations(); } }
/** * Method "tryLock". * * @param key * @param timeout the time to wait for the lock * @param unit the time unit of the timeout argument * @return true if the lock was free and was acquired by the current thread, or the lock was * already held by the current thread; and false if the waiting time elapsed before the lock * could be acquired * @throws InterruptedException * @throws IllegalArgumentException if bean is null * @see java.util.concurrent.locks.ReentrantLock#tryLock(long, java.util.concurrent.TimeUnit) */ @Override public boolean tryLock(final KP key, final long timeout, final TimeUnit unit) throws InterruptedException { blockOperationIfRequired(); incrementRunningOperations(); try { return locker.tryLock(key, timeout, unit); } finally { decrementRunningOperations(); } }
/** * Method "tryLock". * * @param key * @param timeout the time to wait for the lock in milliseconds * @return true if the lock was free and was acquired by the current thread, or the lock was * already held by the current thread; and false if the waiting time elapsed before the lock * could be acquired * @throws InterruptedException * @throws IllegalArgumentException if bean is null * @see java.util.concurrent.locks.ReentrantLock#tryLock(long, java.util.concurrent.TimeUnit) */ @Override public boolean tryLock(final KP key, final long timeout) throws InterruptedException { return locker.tryLock(key, timeout, TimeUnit.MILLISECONDS); }