Loading lesson…
Level 1 · Apprentice0 XP
Heap allocation, shared ownership and interior mutability, single- and multi-threaded.
Step 1 / 6
ProblemA cache is used by several parts of a program, or by several threads. Ownership says one owner. How can many parts share it?
← → step
Before this: Collections, iterators and closures
🛠️ Your turn
Reading is not the skill, doing is. Try for ten minutes before you open the hint. Getting stuck first is what makes the solution stick.
1.Build a thread-safe in-memory cache type Cache<K, V> with Arc<RwLock<HashMap<K, V>>>, with get and insert methods, and test it with 8 threads reading and 2 writing.