/** * Returns the number of times the current thread has entered this monitor in excess of the number * of times it has left. Returns 0 if the current thread is not occupying this monitor. */ public int getOccupiedDepth() { return lock.getHoldCount(); }
/** * Returns the number of times the current thread has entered this monitor in excess of the number * of times it has left. Returns 0 if the current thread is not occupying this monitor. */ public int getOccupiedDepth() { return lock.getHoldCount(); }
/** * Returns the number of times the current thread has entered this monitor in excess of the number * of times it has left. Returns 0 if the current thread is not occupying this monitor. */ public int getOccupiedDepth() { return lock.getHoldCount(); }
/** Leaves this monitor. May be called only by a thread currently occupying this monitor. */ public void leave() { final ReentrantLock lock = this.lock; try { // No need to signal if we will still be holding the lock when we return if (lock.getHoldCount() == 1) { signalNextWaiter(); } } finally { lock.unlock(); // Will throw IllegalMonitorStateException if not held } }
/** Leaves this monitor. May be called only by a thread currently occupying this monitor. */ public void leave() { final ReentrantLock lock = this.lock; try { // No need to signal if we will still be holding the lock when we return if (lock.getHoldCount() == 1) { signalNextWaiter(); } } finally { lock.unlock(); // Will throw IllegalMonitorStateException if not held } }
/** * Release current lock and signal waiters if any */ private void releaseLock() { try { if (lock.getHoldCount() == 1) { signalWaiter(); } } finally { lock.unlock(); } }
/** Leaves this monitor. May be called only by a thread currently occupying this monitor. */ public void leave() { final ReentrantLock lock = this.lock; try { // No need to signal if we will still be holding the lock when we return if (lock.getHoldCount() == 1) { signalNextWaiter(); } } finally { lock.unlock(); // Will throw IllegalMonitorStateException if not held } }
boolean holdsLock(final Object key) { synchronized (locks) { final ReentrantLock lock = (ReentrantLock) locks.get(key); if (lock != null) { return lock.getHoldCount() != 0; } } return false; } /** Stores a value */
boolean holdsLock(final Object key) { synchronized (locks) { final ReentrantLock lock = (ReentrantLock) locks.get(key); if (lock != null) { return lock.getHoldCount() != 0; } } return false; }
public void writeUnLock(final Object key) { synchronized (locks) { final ReentrantLock lock = (ReentrantLock) locks.get(key); if (lock == null) { throw new IllegalMonitorStateException("Cannot unlock prior to locking"); } if (lock.getHoldCount() == 0) { throw new IllegalMonitorStateException("Cannot unlock prior to locking"); } lock.unlock(); if (lock.getHoldCount() == 0) { locks.remove(key); } } }
public void writeUnLock(final Object key) { synchronized (locks) { final ReentrantLock lock = (ReentrantLock) locks.get(key); if (lock == null) { throw new IllegalMonitorStateException("Cannot unlock prior to locking"); } if (lock.getHoldCount() == 0) { throw new IllegalMonitorStateException("Cannot unlock prior to locking"); } lock.unlock(); } } }
public void writeUnLock(final Object key) { synchronized (locks) { final ReentrantLock lock = (ReentrantLock) locks.get(key); if (lock == null) { throw new IllegalMonitorStateException("Cannot unlock prior to locking"); } if (lock.getHoldCount() == 0) { throw new IllegalMonitorStateException("Cannot unlock prior to locking"); } lock.unlock(); // TODO: stop lock from being removed when another worker is trying // to acquire it // TODO: review w/ J2SE 5.0 // if (lock.holds() == 0) { // locks.remove(key); // } } }
@Override public void unlock() { if (!this.delegate.isHeldByCurrentThread()) { throw new IllegalMonitorStateException("You do not own mutex at " + this.path); } if (this.delegate.getHoldCount() > 1) { this.delegate.unlock(); return; } try { this.mutex.delete(this.path); } catch (Exception e) { throw new DataAccessResourceFailureException("Failed to release mutex at " + this.path, e); } finally { this.delegate.unlock(); } }
throw new IllegalStateException("You do not own lock at " + this.lockKey); if (this.localLock.getHoldCount() > 1) { this.localLock.unlock(); return;
/** * Returns the number of times the current thread has entered this monitor in excess of the number * of times it has left. Returns 0 if the current thread is not occupying this monitor. */ public int getOccupiedDepth() { return lock.getHoldCount(); }
/** * Returns the number of times the current thread has entered this monitor in excess of the number * of times it has left. Returns 0 if the current thread is not occupying this monitor. */ public int getOccupiedDepth() { return lock.getHoldCount(); }
/** * Returns the number of times the current thread has entered this monitor in excess of the number * of times it has left. Returns 0 if the current thread is not occupying this monitor. */ public int getOccupiedDepth() { return lock.getHoldCount(); }
/** * Returns the number of times the current thread has entered this monitor in excess of the number * of times it has left. Returns 0 if the current thread is not occupying this monitor. */ public int getOccupiedDepth() { return lock.getHoldCount(); }
if (((ReentrantLock) getLockInstance()).getHoldCount() == 1) { ultimateRelease = true; getService().runPendingAccessTasks(this);
private void lockLog(String method) { if (LOG.isLoggable(Level.FINE)){ LOG.log(Level.FINE, MessageFormat.format("{0} viewLock Hold count :{1}, lock queue count:{2}", method, viewLock.getHoldCount(), viewLock.getQueueLength())); } } }