[concurrency-interest] atomic references

David Holmes dcholmes at optusnet.com.au
Wed Aug 23 00:37:52 EDT 2006


> However, it is not clear if AtomicReference performs an == or an
> equals() comparison. As we know v1 == v2 can be entirely different
> from v1.equals(v2). Can anyone shed some light on which type of
> comparison is done?

If you think about the purpose of atomics it can only be a reference
comparison ==. These are "raw" memory operations. And this is documented in

> Furthermore, assuming the former (==), is it not incongruous for
> AtomicReference to do a reference comparison while other atomics do a
> value comparison (on primitives)? Im curious about this one.

== is always a value comparison - for AtomicReference the value being
compared is a reference.

For non-objects identity and equivalence are the same thing.

David Holmes

More information about the Concurrency-interest mailing list