增加分段锁实现SegmentLock(pr#1330@Gitee)

This commit is contained in:
Looly
2025-04-15 11:27:46 +08:00
parent 54d6b99b98
commit 8a17fae3b7
3 changed files with 12 additions and 3 deletions

View File

@@ -42,6 +42,7 @@ public class SegmentLockTest {
assertEquals(SEGMENT_COUNT, readWriteLock.size());
}
@SuppressWarnings("StringOperationCanBeSimplified")
@Test
public void testGetWithSameKey() {
// 相同 key 应返回相同锁
@@ -132,6 +133,7 @@ public class SegmentLockTest {
assertEquals(1, sem.availablePermits(), "释放一个许可后应为 1");
}
@SuppressWarnings("ResultOfMethodCallIgnored")
@Test
public void testReadWriteLock() throws InterruptedException {
ReadWriteLock rwLock = readWriteLock.get("testKey");