java - ConcurrentHashMap 多线程获取数据时保证其他线程不会插入或者影响?
迷茫
迷茫 2017-04-18 10:49:45
0
4
720

ConcurrentHashMap 多线程获取数据时保证其他线程不会插入或者影响??

迷茫
迷茫

业精于勤,荒于嬉;行成于思,毁于随。

reply all(4)
左手右手慢动作

I don’t understand what the poster wants to ask.

Ty80

Synchronize or use ThreadLocal

伊谢尔伦

ConcurrentHashMap is thread-safe, whether it is put or get

大家讲道理

What the poster wants to ask is whether ConcurrentHashMap will block the put operation when getting?

No
because the array of ConcurrentHashMap is declared like this: transient volatile Node<K,V>[] table;
The get operation just reads the current table array: tab = table. There is no lock.

So it will not block the put operation

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template