[英]Atomic assignment of long value in java
I have the use case to update epoch time of events in a long variable.我有一个用例来更新 long 变量中事件的纪元时间。 This variable will have lots of concurrent reads and writes as well.这个变量也会有很多并发读取和写入。 Here are the requirements in detail:以下是详细要求:
Which of the alternatives is a better option for my use case:哪种替代方案更适合我的用例:
(x,y) -> y
LongAccumulator with accumulatorFunction 是(x,y) -> y
使用AtomicLong
因为它有助于避免显式锁定的额外开销
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.