closeLock 改为unLock

This commit is contained in:
sxq 2021-06-08 15:00:21 +08:00
parent 0786110414
commit 120e6ac1fc
2 changed files with 4 additions and 1 deletions

View File

@ -106,7 +106,7 @@ public class RedisLockManager {
* 释放锁(统一释放) * 释放锁(统一释放)
* @param lock * @param lock
*/ */
public void closeLock(RLock lock){ public void unLock(RLock lock){
lock.unlock(); lock.unlock();
} }
} }

View File

@ -31,9 +31,12 @@ public class TestRedisLockController {
try { try {
RLock rLock = redisLockManager.getLock(key,time, TimeUnit.SECONDS); RLock rLock = redisLockManager.getLock(key,time, TimeUnit.SECONDS);
System.out.println(LocalTime.now().toString() +"获取到锁:"+key); System.out.println(LocalTime.now().toString() +"获取到锁:"+key);
Thread.sleep(3000);
redisLockManager.unLock(rLock);
} catch (InterruptedException e) { } catch (InterruptedException e) {
System.out.println(e.getMessage()); System.out.println(e.getMessage());
} }
return AjaxResult.success(); return AjaxResult.success();
} }
} }