问题
I recently came to know about CAS - Compare and Set
and I tried to know more about it. I checked online in quest to know more and came across this link.
How is it possible that without locking , using CAS
threads can get / update values.
For example, in multicore processors they keep values in their own cache (and that is why we use volatile
when we want threads to read latest values). So, even if, there is CAS
, won't threads trying to do this operation be reading from their own cache?
Are these types of operations to be supported by Hardware? Any inputs, as a novice how to get familiar with this?
来源:https://stackoverflow.com/questions/61916128/cas-based-algorithms-how-threads-sees-latest-values