Java Code Examples for java.util.concurrent.locks.ReentrantLock#getHoldCount()
The following examples show how to use
java.util.concurrent.locks.ReentrantLock#getHoldCount() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: EntityCacheManager.java From jstarcraft-core with Apache License 2.0 | 5 votes |
private void unlockIdLock(K id, ReentrantLock lock) { // 此处可以考虑使用HashLock代替synchronized降低锁竞争 synchronized (idLocks) { lock.unlock(); if (lock.getHoldCount() == 0) { idLocks.remove(id, lock); } } }
Example 2
Source File: EntityCacheManager.java From jstarcraft-core with Apache License 2.0 | 5 votes |
private void unlockIndexLock(CacheIndex index, ReentrantLock lock) { // 此处可以考虑使用HashLock代替synchronized降低锁竞争 synchronized (indexLocks) { lock.unlock(); if (lock.getHoldCount() == 0) { indexLocks.remove(index, lock); } } }
Example 3
Source File: RegionCacheManager.java From jstarcraft-core with Apache License 2.0 | 5 votes |
private void unlockIdLock(K id, ReentrantLock lock) { // 此处可以考虑使用HashLock代替synchronized降低锁竞争 synchronized (idLocks) { lock.unlock(); if (lock.getHoldCount() == 0) { idLocks.remove(id, lock); } } }
Example 4
Source File: RegionCacheManager.java From jstarcraft-core with Apache License 2.0 | 5 votes |
private void unlockIndexLock(CacheIndex index, ReentrantLock lock) { // 此处可以考虑使用HashLock代替synchronized降低锁竞争 synchronized (indexLocks) { lock.unlock(); if (lock.getHoldCount() == 0) { indexLocks.remove(index, lock); } } }
Example 5
Source File: Monitor.java From codebuff with BSD 2-Clause "Simplified" License | 5 votes |
/** * 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 } }
Example 6
Source File: Monitor.java From codebuff with BSD 2-Clause "Simplified" License | 5 votes |
/** * 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 } }
Example 7
Source File: Monitor.java From codebuff with BSD 2-Clause "Simplified" License | 5 votes |
/** * 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 } }
Example 8
Source File: Monitor.java From codebuff with BSD 2-Clause "Simplified" License | 5 votes |
/** * 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 } }
Example 9
Source File: Monitor.java From codebuff with BSD 2-Clause "Simplified" License | 5 votes |
/** * 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 } }
Example 10
Source File: SynchronizationManagerImpl.java From score with Apache License 2.0 | 5 votes |
private void unlockCompletely(ReentrantLock lockToUnlock) { int counter = lockToUnlock.getHoldCount(); for (int i = 0; i < counter; i++) { lockToUnlock.unlock(); } }