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

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


thank you,  this is exactly what I was looking for.
DT
On 9/1/2014 2:23 PM, Stanimir Simeonoff wrote:
> Any reference in Java is strong but the garbage collector has special 
> treatment for Weak/Soft/Phantom ones and only for them.
> AtomicReference allows Read-check-modify (or CAS [Compare-And-Set]) as 
> an atomic operation.
>
> To put it simply AtomicReference doesn't enjoy any special treatment 
> unlike Weak/Soft ones.
>
>
> On Mon, Sep 1, 2014 at 11:30 PM, DT <dt at flyingtroika.com 
> <mailto:dt at flyingtroika.com>> wrote:
>
>
>     thanks, so AtomicReference does not have anything common with a
>     strong reference , is it correct? in the sense how strong
>     reference is implemented.
>
>     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>
>             [mailto: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
>             <mailto:Concurrency-interest at cs.oswego.edu>
>             http://cs.oswego.edu/mailman/listinfo/concurrency-interest
>
>
>     _______________________________________________
>     Concurrency-interest mailing list
>     Concurrency-interest at cs.oswego.edu
>     <mailto:Concurrency-interest at cs.oswego.edu>
>     http://cs.oswego.edu/mailman/listinfo/concurrency-interest
>
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://cs.oswego.edu/pipermail/concurrency-interest/attachments/20140901/81bf6fc1/attachment-0001.html>


More information about the Concurrency-interest mailing list