change lock

This commit is contained in:
Looly
2021-01-24 22:37:12 +08:00
parent a8add399c2
commit bdb078b1ee
3 changed files with 19 additions and 9 deletions

View File

@@ -150,7 +150,7 @@ public abstract class AbstractCache<K, V> implements Cache<K, V> {
final Lock keyLock = keyLockMap.computeIfAbsent(key, k -> new ReentrantLock());
keyLock.lock();
try {
// 双重检查锁
// 双重检查锁,防止在竞争锁的过程中已经有其它线程写入
final CacheObj<K, V> co = cacheMap.get(key);
if (null == co || co.isExpired()) {
try {