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

DT dt at flyingtroika.com
Mon Sep 1 00:48:20 EDT 2014


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


More information about the Concurrency-interest mailing list