|
@@ -1,7 +1,7 @@
|
|
package org.hswebframework.web.concurrent.lok;
|
|
package org.hswebframework.web.concurrent.lok;
|
|
|
|
|
|
-import org.hswebframework.web.concurrent.lock.LockFactory;
|
|
|
|
-import org.hswebframework.web.concurrent.lock.SimpleLockFactory;
|
|
|
|
|
|
+import org.hswebframework.web.concurrent.lock.LockManager;
|
|
|
|
+import org.hswebframework.web.concurrent.lock.SimpleLockManager;
|
|
import org.junit.Assert;
|
|
import org.junit.Assert;
|
|
import org.junit.Test;
|
|
import org.junit.Test;
|
|
|
|
|
|
@@ -16,14 +16,14 @@ import java.util.function.Consumer;
|
|
*/
|
|
*/
|
|
public class SimpleLockTests {
|
|
public class SimpleLockTests {
|
|
|
|
|
|
- private LockFactory lockFactory = new SimpleLockFactory();
|
|
|
|
|
|
+ private LockManager lockManager = new SimpleLockManager();
|
|
|
|
|
|
private long counter = 0;
|
|
private long counter = 0;
|
|
|
|
|
|
@Test
|
|
@Test
|
|
public void testLock() throws InterruptedException {
|
|
public void testLock() throws InterruptedException {
|
|
counter = 0;
|
|
counter = 0;
|
|
- Lock lock = lockFactory.getLock("foo");
|
|
|
|
|
|
+ Lock lock = lockManager.getLock("foo");
|
|
for (int i = 0; i < 100; i++) {
|
|
for (int i = 0; i < 100; i++) {
|
|
new Thread(() -> {
|
|
new Thread(() -> {
|
|
lock.lock();
|
|
lock.lock();
|
|
@@ -40,7 +40,7 @@ public class SimpleLockTests {
|
|
@Test
|
|
@Test
|
|
public void testReadWriteLock() throws InterruptedException {
|
|
public void testReadWriteLock() throws InterruptedException {
|
|
counter = 0;
|
|
counter = 0;
|
|
- ReadWriteLock readWriteLock = lockFactory.getReadWriteLock("foo");
|
|
|
|
|
|
+ ReadWriteLock readWriteLock = lockManager.getReadWriteLock("foo");
|
|
|
|
|
|
Lock readLock = readWriteLock.readLock();
|
|
Lock readLock = readWriteLock.readLock();
|
|
|
|
|