@Test public void ensure_that_calls_with_different_strings_returns_different_locks() { ReentrantReadWriteLockGroup locks = new ReentrantReadWriteLockGroup(true, 3); ReentrantReadWriteLock lock1 = locks.getLock("1"); ReentrantReadWriteLock lock2 = locks.getLock("2"); ReentrantReadWriteLock lock3 = locks.getLock("3"); assertNotEquals(lock1, lock2); assertNotEquals(lock1, lock3); assertNotEquals(lock2, lock3); }
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);  }