1

I was reading various posts about lazySet() method on AtomicInteger, which in-short denotes that visibility of the set value might not be immediately propagated to other threads (it is not a full barrier).

I ran a simple Demo, with multiple readers and one writer. readers periodically read value from AtomicInteger and the writer every 10 ms updates the value. I saw no distinguishable difference between lazySet() and set(). Is it due to x86 and strong coherency model? or sthe store buffers are simply quickly drained?

Bober02
  • 15,034
  • 31
  • 92
  • 178
  • 1
    That question does not answer real use case results and why there is no visible difference in visiblity across threads – Bober02 Jun 29 '17 at 16:25
  • @OldCurmudgeon If you hadn't seen, and wanted to address. – Sotirios Delimanolis Jun 29 '17 at 17:03
  • 1
    Accepted answer for duplicate question contains `but may be reordered with subsequent operations (or equivalently, might not be visible to other threads) until some other volatile write or synchronizing action occurs).`. So if you code uses some syncrhonization actions (e.g. timer-related), there is no difference with `set()`. – Tsyvarev Jun 30 '17 at 19:59
  • I don't think this is a duplicate as this question is specifically concerned with the differences in delay of visibility. – Nitsan Wakart Mar 12 '19 at 17:32

0 Answers0