[concurrency-interest] Fwd: Should I avoid compareAndSet with value-based classes?
david.lloyd at redhat.com
Fri Jul 7 10:02:05 EDT 2017
On Fri, Jul 7, 2017 at 8:52 AM, Andrew Haley <aph at redhat.com> wrote:
> On 07/07/17 14:41, David Lloyd wrote:
>> On Fri, Jul 7, 2017 at 4:20 AM, Andrew Haley <aph at redhat.com> wrote:
>>> In practice it doesn't matter, because you don't need to CAS a
>>> reference to an Instant: all you need to do is to wrap all of the
>> I think you must have meant, "In practice it doesn't matter _in this
>> particular case_". The problem of general data structures which use
>> CAS for updates matters very much in practice.
> I'm talking about the problem of atomically updating an instance of a
> value-based class while multiple threads are accessing it. Unless I
> am very much mistaken this thread is about no other subject.
By my reading of the thread, most of it, if not all of it, is about
the more general problem of atomically updating a reference with CAS
and the behavior of the "compare" part in relation to value classes.
There is a clear problem if you don't know that your target type is a
value class and your JVM aggressively optimizes them in a way which
breaks referential equality in an unexpected way.
More information about the Concurrency-interest