Skip to content

Commit

Permalink
Fix LRUCache.putIfAbsent concurrent issue
Browse files Browse the repository at this point in the history
  • Loading branch information
AlbumenJ committed Sep 2, 2024
1 parent f3d1294 commit d7304aa
Showing 1 changed file with 10 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,16 @@ public void clear() {
}
}

@Override
public V putIfAbsent(K key, V value) {
lock.lock();
try {
return super.putIfAbsent(key, value);
} finally {
lock.unlock();
}
}

public void lock() {
lock.lock();
}
Expand Down

0 comments on commit d7304aa

Please sign in to comment.