It's a producer-consumer setup (multithreaded chatserver) and I have a concurrentmap where I put named printwriter
ConcurrentMap<String, PrintWriter> allNamedPrintwriters = new ConcurrentHashMap<>();
allNamedPrintwriters.put(content, pw);
I would like the main-server to be the one to close the connections based on changes in the allNamedPrintWriters-map (being maintained by the consumer). I don't want any of the other threads to do the job. So they do not have access to the socket - only the readers/writers. Is there an obvious solution to this? A kind of trigger that could be observed?