2013年11月4日星期一

HashMap lock can be achieved with the use of concurrent operations when data will not mess it

HashMap lock can be achieved with the use of concurrent operations when data will not mess it ?
------ Solution ---------------------------------------- ----
hashmap itself is thread safe. No additional protection , then it will be easy synchronization problems , if they implement a hashmap access for synchronous operation is also possible. hashtable itself is thread-safe , can use hashtable ah
------ Solution ---------------------------- ----------------
concurrent operation of the proposed use java.util.concurrent.ConcurrentHashMap
------ Solution ---------- ----------------------------------
can, but the performance is much higher ConcurrentHashMap
- ---- Solution -------------------------------------------- < br> you so and so was the solution to the problem of concurrent calls on the various points you imagine , if the program has 100 places available, you have to write 100 lock. If someone else maintain your code how to engage.
correct approach should be in the source control, is to choose the thread-safe collection .
------ For reference only -------------------------------------- -
ConcurrentHashMap this I know, I would like to ask , with the lock to fit hashMap effects can be synchronized
HashMap object in each operation where all but locked up. So you can do
------ For reference only ----------------------------------- ----
Thank you, I do not know how to write test cases ...
------ For reference only -------------------- -------------------
ah good ! Thank you .

没有评论:

发表评论