ReentrantLock

Preview

synchronized is the right default for a thread-safe LRU. But in a senior interview, the follow-up is often: "When would you reach for ReentrantLock instead?" Both provide the same correctness guarantees — mutual exclusion plus memory visibility. The difference is what you can...

Sign in to read the full chapter.

Checking access…