ReferenceQueue rq=new ReferenceQueue();
SoftReference <class> ob=new SoftReference<class>(object_of_class,rq);

The API says that all weak and soft references are cleared as they are enqueued. So, for the above code, as soon as the JVM sees that "object_of_class" is softly reachable, it will enqueue it, and clear the soft reference. "clearing the soft reference" here means making ob=null or making ob.get() to return null? ob,get() will definitely return null after this, but what is "clearing the soft reference" ?

Reference to the soft reference object in the above code is "ob". So, by clearing it when its enqueued, it should mean making ob=null. But then, what is being enqueued, if not ob ?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.