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

David Holmes davidcholmes at aapt.net.au
Mon Sep 1 17:11:31 EDT 2014


DT writes:
>
> thanks, so AtomicReference does not have anything common with a strong
> reference , is it correct? in the sense how strong reference is
> implemented.

What do you mean by "how strong reference is implemented"? There is no type
"strong reference" - any field of reference type that holds a reference to
an object is a strong reference. Even WeakReference/SoftReference hold
strong references to their referents - it is the GC that clears those strong
references when it needs to.

Atomic Reference has nothing to do with the functionality of the
java.lang.ref package.

Cheers,
David Holmes

>
> DT
> On 9/1/2014 1:29 AM, David Holmes wrote:
> > 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