[concurrency-interest] AtomicReference and java.lang.ref packagedesign thoughts

David Holmes davidcholmes at aapt.net.au
Mon Sep 1 04:29:04 EDT 2014


Hi DT,

AtomicReference is an atomic class that operates on object references as
opposed to one of the primitive types.

The java.lang.ref package concerns types that manage references to other
objects for the purpose of interacting with the garbage collector.

AtomicReference has nothing to do with interacting with the garbage
collector.

Cheers,
David Holmes

> -----Original Message-----
> From: concurrency-interest-bounces at cs.oswego.edu
> [mailto:concurrency-interest-bounces at cs.oswego.edu]On Behalf Of DT
> Sent: Monday, 1 September 2014 2:48 PM
> To: concurrency-interest
> Subject: [concurrency-interest] AtomicReference and java.lang.ref
> packagedesign thoughts
>
>
> Are any plans to move AtomicReference to the java.lang.ref package? Just
> interesting to understand what was the idea behind the AtomicReference
> implementation. AtomicReference is used for concurrency reason and its
> some sort of a strong reference. So it makes sense to put it under
> concurrency package but at the same time it represents a reference
> object and the construct for Atomicreference is the same as any other
> references - AtomicReference aRef_ = new AtomicReference() , or
> SoftReference sRef_ = new SoftReference();
> The ref package has multiple reference implementations such as
> Reference, PhantomReference, SoftReference, WeakReference  - and all of
> them are managed by ReferenceQueue in the direct or abstract way, though
> AtomicReference does not belong to  ref package and is not extended from
> Reference class. My understanding is that its not meant to be used in
> any way with a ReferenceQueue for any type of weak cache implementations
> either. So should it be under the ref package or under concurrency
> package if we look at this from high level?
> Seems to me there is some misconception about references which makes it
> hard to understand in terms of the memory and gc behaviors.
>
> Thanks,
> DT
> _______________________________________________
> Concurrency-interest mailing list
> Concurrency-interest at cs.oswego.edu
> http://cs.oswego.edu/mailman/listinfo/concurrency-interest



More information about the Concurrency-interest mailing list