Back
Close

Computing with Data

elgeish
86.2K views

Reader-Writer Locks - Part III

Of course there are many improvements we can make here to reduce contention; for example, following the best practice of reducing the time a thread spends inside a critical section:

import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
class Reader extends Consumer implements Runnable {
public void run() {
int[] deepCopy;
synchronized (Shared.cache) {
int[] value = Shared.cache.get("key");
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Create your playground on Tech.io
This playground was created on Tech.io, our hands-on, knowledge-sharing platform for developers.
Go to tech.io
codingame x discord
Join the CodinGame community on Discord to chat about puzzle contributions, challenges, streams, blog articles - all that good stuff!
JOIN US ON DISCORD
Online Participants