↧
Answer by Giovanni for Java ConcurrentHashMap and synchronization
No you don't have to synchonize the containsKey api if the Class is ConcurrentHashMap because as stated in the documentation its operations are thread safe (You can read all the documentation in order...
View ArticleAnswer by P.J.Meisch for Java ConcurrentHashMap and synchronization
If you are using Java 8, you can check with the following code:registeredClients.computeIfAbsent(client, c -> {throw new UnknownClientException();});The check if the key exists and the execution of...
View ArticleJava ConcurrentHashMap and synchronization
Let's say that I have a ConcurrentHashMap of clients registered to a server (inside a class Server):Map<ClientID, String> registeredClients = new ConcurrentHashMap<ClientID, String>();In my...
View Article