concurrenthashmap « Thread Safe « Java Thread Q&A

Home
Java Thread Q&A
1.concurrency
2.Development
3.Exception
4.Notify
5.Operation
6.Socket
7.State
8.synchronize
9.Thread Safe
10.ThreadPool
Java Thread Q&A » Thread Safe » concurrenthashmap 

1. Java ConcurrentHashMap not thread safe.. wth?    stackoverflow.com

I was using HashMap before like

   public Map<SocketChannel, UserProfile> clients = new HashMap<SocketChannel, UserProfile>();
now I've switched to ConcurrentHashMap to avoid synchronized blocks and now i'm experiencing problems my ...

2. Is read/writing from/in ConcurrentHashMap in ConcurrentHashMap thread safe?    coderanch.com

Each map is synchronized separately, and the method calls you show are not different than handling the calls on different lines: String value = a.get("key1").get("key2"); /* is equivalant to */ Map b = a.get("key1"); String value = b.get("key2"); So getting the Map from a is thread safe in that a will not be modified while the get() occurs. Similarly getting the ...

java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.