Quantcast
Channel: Java ConcurrentHashMap and synchronization - Stack Overflow
Browsing all 3 articles
Browse latest View live

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 Article


Answer 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 Article


Java 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
Browsing all 3 articles
Browse latest View live


Latest Images