宛渠日古
搜尋
WIKI专题
并发编程
数据库
Linux/Unix
网络相关
非技术
诗集
工具箱
近期變更
文章分类
全部文章
說明
連結至此的頁面
相關變更
特殊頁面
頁面資訊
登入
頁面
討論
views
閱讀
檢視原始碼
歷史
檢視 Java:LongAdder 的原始碼
由於下列原因,您沒有權限進行編輯此頁面的動作:
您請求的操作只有這個群組的使用者能使用:
使用者
您可以檢視並複製此頁面的原始碼。
LongAdder跟AtomicLong功能类似,但是在高竞争的场景下表现更优。例如结合ConcurrentHashMap来维护一个频率列表: <syntaxhighlight lang="java"> ConcurrentHashMap<String,LongAdder> freqs; //... freqs.computeIfAbsent(key, k -> new LongAdder()).increment();} </syntaxhighlight> <q> The implementation extends Striped64, which is a data holder for 64-bit values. The values are held in cells, which are padded (or striped), hence the name. Each operation made upon the LongAdder will modify the collection of values present in the Striped64. When contention occurs, a new cell is created and modified, so the the old thread can finish concurrently with contending one. When you need the final value, the sums of each cell is simply added up. </q> [[Category:Concurrency]]
返回「
Java:LongAdder
」頁面