@Test public void ensure_that_two_different_locks_are_returned_when_threshold_is_reached() { ReentrantReadWriteLockGroup locks = new ReentrantReadWriteLockGroup(true, 1); ReentrantReadWriteLock firstLockForOneValue = locks.getLock("1"); ReentrantReadWriteLock firstLockForTwoValue = locks.getLock("2"); ReentrantReadWriteLock secondLockForOneValue = locks.getLock("1"); ReentrantReadWriteLock secondLockForTwoValue = locks.getLock("2"); assertNotEquals(firstLockForOneValue, secondLockForOneValue); assertNotEquals(firstLockForTwoValue, secondLockForTwoValue); }
public ReentrantReadWriteLock getLock(String id) { ReentrantReadWriteLock lock = locks.get(id); if (lock == null) { locks.putIfAbsent(id, new ReentrantReadWriteLock(fairness)); } lock = locks.get(id); if (CLEANUP_THRESHOLD <= ++counter) { cleanUp(lock); counter = 0; } return lock; }
ReentrantReadWriteLockGroup { public ReentrantReadWriteLock getLock(String id) { ReentrantReadWriteLock lock = locks.get(id); if (lock == null) { locks.putIfAbsent(id, new ReentrantReadWriteLock(fairness)); } lock = locks.get(id); if (CLEANUP_THRESHOLD <= ++counter) { cleanUp(lock); counter = 0; } return lock; } }
ReentrantReadWriteLockGroup { public ReentrantReadWriteLock getLock(String id) { ReentrantReadWriteLock lock = locks.get(id); if (lock == null) { locks.putIfAbsent(id, new ReentrantReadWriteLock(fairness)); } lock = locks.get(id); if (CLEANUP_THRESHOLD <= ++counter) { cleanUp(lock); counter = 0; } return lock; } ReentrantReadWriteLockGroup();  ReentrantReadWriteLockGroup(int counter);  ReentrantReadWriteLockGroup(boolean fairness);  ReentrantReadWriteLockGroup(boolean fairness, int counter); }
ReentrantReadWriteLockGroup { public ReentrantReadWriteLock getLock(String id) { ReentrantReadWriteLock lock = locks.get(id); if (lock == null) { locks.putIfAbsent(id, new ReentrantReadWriteLock(fairness)); } lock = locks.get(id); if (CLEANUP_THRESHOLD <= ++counter) { cleanUp(lock); counter = 0; } return lock; } ReentrantReadWriteLockGroup();  ReentrantReadWriteLockGroup(int counter);  ReentrantReadWriteLockGroup(boolean fairness);  ReentrantReadWriteLockGroup(boolean fairness, int counter); ReentrantReadWriteLock getLock(String id); }
ReentrantReadWriteLockGroup { public ReentrantReadWriteLock getLock(String id) { ReentrantReadWriteLock lock = locks.get(id); if (lock == null) { locks.putIfAbsent(id, new ReentrantReadWriteLock(fairness)); } lock = locks.get(id); if (CLEANUP_THRESHOLD <= ++counter) { cleanUp(lock); counter = 0; } return lock; } ReentrantReadWriteLockGroup();  ReentrantReadWriteLockGroup(int counter);  ReentrantReadWriteLockGroup(boolean fairness);  ReentrantReadWriteLockGroup(boolean fairness, int counter); ReentrantReadWriteLock getLock(String id);  }